Last active
August 8, 2018 02:21
-
-
Save 1RedOne/1437ac12335ebf3761de6314a1c0a0a7 to your computer and use it in GitHub Desktop.
A scratch of swapping a dash for a period in AD>
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
if ($user.Surname){ | |
"$user has a surname" | |
$newSurname = $user.Surname.ToUpper() | |
"changing to $newSurname" | |
$user | Set-ADUser -Surname $newSurname -WhatIf | |
} |
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
$users =Get-ADUser -Filter * -Properties telephonenumber | |
#Step through each object in $users, calling the current object $user | |
ForEach ($user in $users){ | |
#If the user has a telephone number property, they have a number set in AD. If so, run this next script block | |
if ($user.telephonenumber){ | |
#Make a temporary variable to hold the users new number | |
$newphone = $user.telephonenumber.Replace('-','.') | |
#Every string in .net has a .Replace method. We use it to swap a '-' for a '.' | |
#Echo out to the screen what we're doing | |
"changing $($user.Name) Phone from $($user.telephonenumber) to $newphone" | |
#Set the phonenumber in AD | |
$user | Set-ADUser -OfficePhone $newphone -Verbose -WhatIf | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment