Quantcast
Channel: SQLServerCentral » Programming » Powershell » Latest topics
Viewing all articles
Browse latest Browse all 467

Move Logins via SMO

$
0
0
It's possible to create in Powershell, a script that move the login from a source server to a destination server, including the password ?I tried to use the sp_help_revlogin procedure, but I'm unable to get the t-sql output into a variable.[code="sql"]$handler = [System.Data.SqlClient.SqlInfoMessageEventHandler] {param($sender, $event) $LoginDes | Write-Host $event.Message };$smoSrc.connectionContext.add_InfoMessage($handler);$smoSrc.connectionContext.executeNonQuery("EXEC master..sp_help_revlogin $dbLogin")[/code]If a try to use the script() method, the code generated has the password field, but is not the sid value.Tks

Viewing all articles
Browse latest Browse all 467

Trending Articles