Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Help with a filter

$
0
0

I'm trying to filter out some AD users who have "ACE" as their Company in Active Directory.  I only want users who have logged on in the last 60 days,  don’t have “Long Term Absence” or “Intermittent User” in their Description (Help desk can’t spell intermittent so I have to search for intermttant as well).

My problem is all those users with a blank Description don’t get picked up. So how do I get them included?

 

$60Days=((Get-Date).AddDays(-60)).Date

$staff=Get-AdUser-properties*-searchbase$OU-Filter {(company-Like"ACE*") -And (lastlogondate-ge$60days) -And (Description-notlike"*long term absence*") -and (Description-notlike"*Intermittent User*") -and (Description-notlike"*Intermittant User*")} |select-objectname,company,SAMaccountname,passwordExpired,PasswordNeverExpires,logoncount,whenCreated,lastlogondate,Manager,EmployeeNumber,Enabled,lastLogonTimestamp,PasswordLastSet,Description, @{n='LastLogon';e={[DateTime]::FromFileTime($_.LastLogon)}}, @{n='lastLogonTimestamp  ';e={[DateTime]::FromFileTime($_.lastLogonTimestamp  )}}

$staff|Export-Csvc:\ACE.csv

 

 


Viewing all articles
Browse latest Browse all 6937

Latest Images

Trending Articles



Latest Images