Link to home
Start Free TrialLog in
Avatar of VIVEKANANDHAN_PERIASAMY
VIVEKANANDHAN_PERIASAMY

asked on

Need Powershell script to take syslogins backup

Need Powershell script to take syslogins backup and should save the syslogins in the remote server(UNC)
Avatar of DBAduck - Ben Miller
DBAduck - Ben Miller
Flag of United States of America image

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.
ASKER CERTIFIED SOLUTION
Avatar of Brent Challis
Brent Challis
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial