Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Filtering multiple values in PowerShell

$
0
0

So I'm working on a cool PowerShell script but I'm hung up filtering out objects that have different descriptions in their AD User Object.

Here's the command I'm trying in the script. I'm sure I'm not parsing the array properly so I'm looking for some help.

$then = (Get-Date).AddDays(-90) # The 90 is the number of days from today since the last logon.
$descriptions = "Service Account", "Administrative(Non-Personal)"
Get-ADUser -Property Name,lastLogonDate, Description -Filter {(lastLogonDate -lt $then) -and (description -ne $descriptions)} | FT Name, Description, lastLogonDate

I''m borrowing some of the code from @semicolon'sFind and Disable or Remove Inactive AD Computer Accounts PowerShell script. This was a great script to get started working with AD accounts.


Viewing all articles
Browse latest Browse all 15370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>