Change local admin password on multiple machines with PowerShell.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$computers = "srv1","srv2","srv3" $adminPassword = "PAssW00rrrDdd123" $logfile = "log.txt" $ErrorActionPreference = 'stop' ForEach ($computerName in $computers){ Try { $adminUser = [ADSI] "WinNT://$computerName/Administrator,User" $adminUser.SetPassword($adminPassword) } Catch { "$(get-date) :: Server:$($computerName) :: $($error[0].exception)" | Out-File -append $logfile } } |