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


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())



$instanceName = $InstanceList.Name;


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


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


Newer Older