Last active
June 21, 2017 12:59
-
-
Save mrik23/f7add4fcc82f89250b7c6bd73f5d0a52 to your computer and use it in GitHub Desktop.
PowerShell script for Active Directory. In "one" line script we are able to retrieve users based on a specific attribute and update some attributes to them.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
This is an example on how to filter out users based on some standard filter and non-standard attribute. | |
In this case we pull all active users with the company Contoso, we force the attribute countryCode to be retrieved. | |
Then we select the users that have the countryCode empty and finally set the correct attributes for these users. | |
#> | |
$Users = Get-ADUser -Filter 'enabled -eq $true -and company -eq "Contoso"'` | |
-SearchBase "OU=Texas,DC=Contoso,DC=com"` | |
-Properties Department, Title, countryCode | ` | |
where {$_.countryCode -eq ""} | ` | |
Set-ADUser -Replace @{c="US";co="United States";countrycode=840} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment