I have got the script below, it will change the password for a SQL login. Its a powershell script that accepts a string password and will go in to change the password on the SQL instance.
param(
[string] $login_to_change,
[string] $new_password
)
$sql_command "alter login [$login_to_change] with password = '$new_password' "
Invoke-Sqlcmd -ServerInstance $server_instance -Database 'master' -query $sql_command
Is there a way to use securestring within the script file ?. What I am trying to do is avoid a situation where the password can be printed from the script.
When I convert to a securestring, I get the string. 'System.Security.Securestring'
EDIT 1
Its an automated deployment tool that will be calling the script. The reason why i want to encrypt it inside the script for now is that sometimes the automated tool does a print out of commands etc, so if I printed out a command whilst debugging, I dont want it to print out the password in plain text.
The end state will be such that the password string sent to the script will be encrypted. This is just a temporary measure.