-1

What I am trying to do is that there are a lot of user id's in our Windows Active Directory that when you go to the properties of the id's, in the "Office" field, it says (for this example) "test this". I was wondering if there is a way to write in PowerShell to find all the users in Active Directory with "test this" written in the "office" field, and then to remove the words "test this" from the Office field.

Any help is greatly appreciated!

Charles Ryan
  • 23
  • 2
  • 3
  • 9

1 Answers1

2

You can do this using the -LDAPFilter param for Get-AdUser, like so:

Get-ADUser -LDAPFilter “(office='test this')”

Should give you a listing of all the users with 'Test this' in their office property. Run that first and confirm it gives you the list you'd like.

Next, to mass change the value:

Get-ADUser -LDAPFilter “(office='test this')” | Set-AdUser -Clear office -whatif

Run that once in WhatIf mode to see what would happen, and if you're happy with it, then remove -Whatif to run it in production.

FoxDeploy
  • 12,569
  • 2
  • 33
  • 48