Need Powershell script to take syslogins backup

VIVEKANANDHAN_PERIASAMY
VIVEKANANDHAN_PERIASAMY used Ask the Experts™
on
Need Powershell script to take syslogins backup and should save the syslogins in the remote server(UNC)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
It would probably be simpler to run the sp_helprevlogin in the master database and save off the result.  This could be run in PowerShell as well.

Take a look here and put these in your master database:
http://support.microsoft.com/kb/918992

Then you can run the following script and get your information out.

$server = New-Object Microsoft.SqlServer.Management.Smo.Server servername
$db = $server.Databases["master"]
$ds = $db.ExecuteWithResults("EXEC sp_helprevlogin")

$ds.Tables[0] | Export-CSV "c:\temp\logins.csv"

or something like that.
Commented:
Why not use T-SQL to back up the data, or and SSIS package generated by the Tasks Export from SQL Server Management Studio,

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial