Posted in
Windows Powershell |
2 Comments | 1,232 views | 02/03/2016 16:12
You can get detailed SQL Server properties via following code:
1
2
3
4
5
6
7
8
9
10
11
12
13
| $MSSQLServerManager = New-Object 'Microsoft.SqlServer.Management.SMO.Server'
# Get SQL Logins
$MSSQLLogin = @($MSSQLServerManager.Logins)[0]
# Get SQL Logins Properties
$HostSQLLoginName = $MSSQLLogin.Name;
$HostSQLLoginType = $MSSQLLogin.LoginType;
$HostSQLLanguage = $MSSQLLogin.Language;
$HostSQLHasAccess = $MSSQLLogin.HasAccess;
$HostSQLDenyWindowsLogin = $MSSQLLogin.DenyWindowsLogin;
$HostSQLIsDisabled = $MSSQLLogin.IsDisabled;
$HostSQLIsLocked = $MSSQLLogin.IsLocked; |
$MSSQLServerManager = New-Object 'Microsoft.SqlServer.Management.SMO.Server'
# Get SQL Logins
$MSSQLLogin = @($MSSQLServerManager.Logins)[0]
# Get SQL Logins Properties
$HostSQLLoginName = $MSSQLLogin.Name;
$HostSQLLoginType = $MSSQLLogin.LoginType;
$HostSQLLanguage = $MSSQLLogin.Language;
$HostSQLHasAccess = $MSSQLLogin.HasAccess;
$HostSQLDenyWindowsLogin = $MSSQLLogin.DenyWindowsLogin;
$HostSQLIsDisabled = $MSSQLLogin.IsDisabled;
$HostSQLIsLocked = $MSSQLLogin.IsLocked;
You can also check other properties by listing all properties of $MSSQLLogin.