ServerConnection.ChangePassword Method (SecureString)

Changes the login password that is used with standard authentication.

Namespace:  Microsoft.SqlServer.Management.Common
Assembly:  Microsoft.SqlServer.ConnectionInfo (in Microsoft.SqlServer.ConnectionInfo.dll)

public void ChangePassword(
	SecureString newPassword
)

Parameters

newPassword
Type: SecureString
A SecureString value that specifies the new password.

C#

ServerConnection conn = new ServerConnection();
conn.LoginSecure = false;
conn.Login = vlogin;
conn.password = vpassword;
conn.ChangePassword(newpassword);

PowerShell

$conn = new-object Microsoft.SqlServer.Management.Common.ServerConnection
$conn.LoginSecure = $FALSE
$conn.Login = vlogin
$conn.Password = vpassword
$conn.ChangePassword newpassword

Reference

Other Resources

Configuring SQL Server Access for SQL Server Authentication

Community Additions

Show: