Import-Module ActiveDirectory
$u = Get-ADUser 'test.caregiver' -Properties mail
Set-ADUser $u -UserPrincipalName 'pilot.test@cascadestucson.com' -EmailAddress 'pilot.test@cascadestucson.com' -SamAccountName 'pilot.test'
Rename-ADObject -Identity $u.DistinguishedName -NewName 'Pilot Test (Caregiver)'
$v = Get-ADUser 'pilot.test' -Properties mail, MemberOf
Write-Output "sAM: $($v.SamAccountName)  UPN: $($v.UserPrincipalName)  mail: $($v.mail)"
Write-Output "DN: $($v.DistinguishedName)"
Write-Output "Groups: $($v.MemberOf -join '; ')"
try { Import-Module ADSync -ErrorAction Stop; Start-ADSyncSyncCycle -PolicyType Delta | Out-Null; Write-Output 'Delta sync started' } catch { Write-Output "Delta sync skipped: $_" }
