Wednesday, February 22, 2012

SqlSecureString

SqlSecureString - It’s a foolish little object type somewhere inside SQL Server that is a pain when it comes to PowerShell (PS).  One of the challenges of a PS script is being able to use passwords within the script.  Several times in creating a “CompleteImage” script for SQL Server 2008, I kept getting an error message that my password values are not of type SqlSecureString.

How did my team fix this?  By defining the password string variables as follows:

$newPwd = convertTo-Securestring “MyPassword” –AsPlainText –Force

No comments:

Post a Comment