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

SQL Logins output to a file via sp_help_revlogin

$
0
0
Hi all,I'm looking to get sql logins output to a file via powershell.After many different, but unsuccessful searches to find a PS script to retrieve SQL Logins via the stored proc sp_help_revlogin, I'm at a loss.Hopefully someone can help. Here's the code which returns a "0" when run. $SqlConnection = New-Object System.Data.SqlClient.SqlConnection$SqlConnection.ConnectionString = "server=srvname\instname;database=master;Integrated Security=sspi"$SqlCmd = New-Object System.Data.SqlClient.SqlCommand$SqlCmd.CommandText = "sp_help_revlogin"$SqlCmd.Connection = $SqlConnection$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter$SqlAdapter.SelectCommand = $SqlCmd$DataSet = New-Object System.Data.DataSet$SqlAdapter.Fill($DataSet) | out-File $outfile -append$SqlConnection.Close()$DataSet.Tables[0]returns: 0This works with a stproc like sp_helpdb, but not sp_help_revlogin. Suggestions?Thank you-RR

Viewing all articles
Browse latest Browse all 467

Trending Articles