September 16, 2022 at 12:00 am
Comments posted to this topic are about the item How to Use PowerShell to Set Secure SA Passwords in Bulk
September 28, 2023 at 12:13 pm
Hi Vincent. Excellent article. I am getting a small error in resetting the SA password. Its in Bulk Reset the SA passwords script. Please let me know if I need to change something.
sapwd : The term 'sapwd' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Work\SA_Password\Bulk_Change_SA_Password.ps1:5 char:111
+ ... e -Database master -Query "ALTER LOGIN sa WITH PASSWORD = '$(sapwd)';
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (sapwd:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
August 16, 2025 at 9:01 am
the script was tested successfully on my server, can you run:
$Servers = Import-Csv "C:\Users\***\Desktop\SQL_SA_pwd.csv"
foreach ($Server in $Servers) {
$sa = $Server.SaPassword
$StringArray = "sapwd=$sa"
and echo $StringArray to test if password string array already created.
thank you
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply