Here is how you change the sa password for your sql servers via powershell. Use with caution, marginally tested. Make sure your sa password is somewhat complex or this will throw an exception.
import-module SqlPS -DisableNameChecking [string]$newPwd = 'C0mp13xP@55word%' try{ gc -Path c:\Servers.txt | %{ $srvName = $_ $srv = New-Object Microsoft.SqlServer.Management.Smo.Server $srvName $srv.Logins | where{$_.Name -eq 'sa'} | %{ $_.ChangePassword($newPwd); } } } catch{ $_ | fl -Force }
Leave a comment