Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Generates a list of users from OU listed in SearchBase that have a .LOCAL upn and are enabled
- $users = Get-ADUser -Searchbase 'OU=OU,DC=DOMAIN,DC=Local' -Filter {(UserPrincipalName -like '*.local') -and (Enabled -eq $true)}
- #loop through each user in the list
- foreach($user in $users){
- #Generates the first half of the UPN as firstname.lastname
- $upn = "$($user.Givenname)" + '.' + "$($user.Surname)"
- #sets the UPN of the account to the previously created $UPN variable @domain.local
- }
Advertisement
Add Comment
Please, Sign In to add comment