2024-02-02 10:12:28 -07:00
|
|
|
<#
|
|
|
|
Sets user Country and Company Fields
|
|
|
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
if (!($cred)) {
|
|
|
|
|
|
|
|
$cred = Get-Credential
|
|
|
|
}
|
|
|
|
$countryHash = @{
|
|
|
|
# canada is 124
|
|
|
|
countryCode = 0124
|
|
|
|
}
|
|
|
|
$CompanyName = 'MPE, a Division of Englobe'
|
|
|
|
|
2024-02-02 10:31:12 -07:00
|
|
|
$User = Get-ADUser -Filter * -SearchBase 'OU=MPEUsers,DC=mpe,DC=ca' -Properties c, co, countryCode
|
2024-02-02 10:12:28 -07:00
|
|
|
foreach ($u in $User) {
|
2024-02-02 10:31:12 -07:00
|
|
|
$u | Set-ADUser -Replace @{ Company = $CompanyName } -Credential $cred
|
2024-02-02 10:12:28 -07:00
|
|
|
$u | Set-ADUser -Country 'CA' -Credential $cred
|
|
|
|
if ($u.countryCode -eq 0 ) {
|
2024-02-02 10:31:12 -07:00
|
|
|
# Write-Output $u.Name
|
2024-02-02 10:12:28 -07:00
|
|
|
$u | set-adobject -Add $countryHash -Credential $cred -ErrorAction SilentlyContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|