# --- CONFIGURABLE VALUES --- $Cred = New-Object System.Management.Automation.PSCredential ($Username, $Password) $ID = '%AccName%' $loc = '%locPostCode%' # new postal code value $mgr = (Get-ADUser -Identity $ID).DistinguishedName # ---------------------------- # For logging $logPath = 'C:\Temp\ADUser_Log.txt' if (-not (Test-Path (Split-Path $logPath))) { New-Item -ItemType Directory -Force -Path (Split-Path $logPath) | Out-Null } Write-Host "Running Set-ADUser as $Username to update PostalCode to $loc ..." Start-Process powershell.exe ` -Credential $Cred ` -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"Import-Module ActiveDirectory; Set-ADUser -Identity '$ID' -PostalCode '$loc' -Manager '$manDN' -ErrorAction Stop; Write-Output 'SUCCESS: PostalCode updated to $loc' | Out-File -FilePath '$logPath' -Append`"" ` -Wait -WindowStyle Hidden Write-Host "Finished. Check $logPath for results."
Write-Host $mgr
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
In our never-ending quest to improve we are simplifying the forum hierarchy…
We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Michael E. Gernaey 462 Super User 2025 Season 2
Tomac 456 Moderator
abm abm 243 Most Valuable Professional