ADScripts/UsersCountry.ps1
2023-09-14 11:13:58 -06:00

17 lines
445 B
PowerShell

$cred=Get-Credential
$countryHash = @{
# canada is 124
countryCode = 0124
}
$User=Get-ADUser -Filter * -SearchBase 'OU=MPEUsers,DC=mpe,DC=ca' -Properties c,co,countryCode | Where-Object countryCode -NE 124
foreach ($u in $User){
$u | Set-ADUser -Country 'CA' -Credential $cred
if ($u.countryCode -eq 0 ) {
Write-Output $u.Name
$u | set-adobject -Add $countryHash -Credential $cred -ErrorAction SilentlyContinue
}
}