[SQL]Search Password Policy Enforced setting for all visible SQL Instance in Local LAN

2013-12-15

Situation:
Basically if you want to know what’s the Login policy for you DB instance, we used to use this T-SQL command
select * from sys.sql_logins


They will tell you some relevant info.

But if you want to know multi instances around your Local Network environment, how to do that?

Login each SQL server and type this command?? Yes, it is a way to reach this. But are there any other ways that I can do this?

Yes, “PowerShell


Open you PowerShell and type this command, used “SMO” class


[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.Smo') | out-null

foreach ($InstanceList in [Microsoft.SqlServer.Management.Smo.SmoApplication]::EnumAvailableSqlServers())

{

$InstanceList;

$instanceName = $InstanceList.Name;

$instanceName;

$SMOserver = New-Object ('Microsoft.SqlServer.Management.Smo.Server')

$instanceName

$db = $SMOserver.Logins | where-object {$_.loginType -eq “sqllogin”} | select name, PasswordPolicyEnforced

$db;

}
Newer Older