Jump to content

Powershell - Display users with specific "description" field content


Recommended Posts

Posted

Hi all,

 

I was wondering if someone would be able to help me with a bit of Powershell I’d like to put together?

 

I am looking to build a script which outputs users under specific OU’s that contain the words “User Expired” within the description field. In a nutshell, I am building a script to go through and remove users that have this - I have several hundred, and would rather not go through them one at a time...!

 

Can anyone help?

 

Many thanks!

 

Jason

Posted

Try

get-ADUser -Filter * -Properties * -SearchBase $OUName | where {$_.Description -like "*$description*"}| ft Name, Description

 

Change $Description and $OUName as required eg:

 

EG:

get-ADUser -Filter * -Properties * -SearchBase "ou=users,ou=someou,dc=domain,dc=local"| where {$_.Description -like "*User Expired*"}| ft Name, Description 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...