Posted in Windows Powershell | No Comment | 1,015 views | 22/02/2016 11:02
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'
$HostSQLAuditLevel = $MSSQLServerManager.AuditLevel;
$HostSQLBuildClrVersionString = $MSSQLServerManager.BuildClrVersionString;
$HostSQLIsCaseSensitive = $MSSQLServerManager.IsCaseSensitive;
$HostSQLIsClustered = $MSSQLServerManager.IsClustered;
$HostSQLIsFullTextInstalled = $MSSQLServerManager.IsFullTextInstalled;
$HostSQLIsHadrEnabled = $MSSQLServerManager.IsHadrEnabled;
$HostSQLIsSingleUser = $MSSQLServerManager.IsSingleUser;
$HostSQLIsXTPSupported = $MSSQLServerManager.IsXTPSupported;
$HostSQLTcpEnabled = $MSSQLServerManager.TcpEnabled;
$HostSQLDefaultTextMode = $MSSQLServerManager.DefaultTextMode;
$HostSQLMaxPrecision = $MSSQLServerManager.MaxPrecision;
$HostSQLNamedPipesEnabled = $MSSQLServerManager.NamedPipesEnabled; |
$MSSQLServerManager = New-Object 'Microsoft.SqlServer.Management.SMO.Server'
$HostSQLAuditLevel = $MSSQLServerManager.AuditLevel;
$HostSQLBuildClrVersionString = $MSSQLServerManager.BuildClrVersionString;
$HostSQLIsCaseSensitive = $MSSQLServerManager.IsCaseSensitive;
$HostSQLIsClustered = $MSSQLServerManager.IsClustered;
$HostSQLIsFullTextInstalled = $MSSQLServerManager.IsFullTextInstalled;
$HostSQLIsHadrEnabled = $MSSQLServerManager.IsHadrEnabled;
$HostSQLIsSingleUser = $MSSQLServerManager.IsSingleUser;
$HostSQLIsXTPSupported = $MSSQLServerManager.IsXTPSupported;
$HostSQLTcpEnabled = $MSSQLServerManager.TcpEnabled;
$HostSQLDefaultTextMode = $MSSQLServerManager.DefaultTextMode;
$HostSQLMaxPrecision = $MSSQLServerManager.MaxPrecision;
$HostSQLNamedPipesEnabled = $MSSQLServerManager.NamedPipesEnabled;
You can also check other properties by listing all properties of $MSSQLServerManager.
Posted in Windows Powershell | No Comment | 957 views | 15/02/2016 15:09
You can get SQL Server Endpoint information 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 Endpoints
$MSSQLEndpoint = @($MSSQLServerManager.Endpoints)[0]
# Get SQL Endpoint Properties
$HostSQLEndpointName = $MSSQLEndpoint.Name;
$HostSQLEndpointType = $MSSQLEndpoint.EndpointType;
$HostSQLProtocolType = $MSSQLEndpoint.ProtocolType;
$HostSQLOwner = $MSSQLEndpoint.Owner;
$HostSQLEndpointState = $MSSQLEndpoint.EndpointState;
$HostSQLIsAdminEndpoint = $MSSQLEndpoint.IsAdminEndpoint;
$HostSQLIsSystemObject = $MSSQLEndpoint.IsSystemObject; |
$MSSQLServerManager = New-Object 'Microsoft.SqlServer.Management.SMO.Server'
# Get SQL Endpoints
$MSSQLEndpoint = @($MSSQLServerManager.Endpoints)[0]
# Get SQL Endpoint Properties
$HostSQLEndpointName = $MSSQLEndpoint.Name;
$HostSQLEndpointType = $MSSQLEndpoint.EndpointType;
$HostSQLProtocolType = $MSSQLEndpoint.ProtocolType;
$HostSQLOwner = $MSSQLEndpoint.Owner;
$HostSQLEndpointState = $MSSQLEndpoint.EndpointState;
$HostSQLIsAdminEndpoint = $MSSQLEndpoint.IsAdminEndpoint;
$HostSQLIsSystemObject = $MSSQLEndpoint.IsSystemObject;
You can also check other properties by listing all properties of $MSSQLEndpoint.
Posted in Windows Powershell | No Comment | 582 views | 07/02/2016 16:56
You can get detailed Service Account information via following code:
1
2
3
4
5
| $MSSQLServerManager = New-Object 'Microsoft.SqlServer.Management.SMO.Server'
$HostSQLServiceAccount = $MSSQLServerManager.ServiceAccount;
$HostSQLServiceInstanceId = $MSSQLServerManager.ServiceInstanceId;
$HostSQLServiceName = $MSSQLServerManager.ServiceName;
$HostSQLServiceStartMode = $MSSQLServerManager.ServiceStartMode; |
$MSSQLServerManager = New-Object 'Microsoft.SqlServer.Management.SMO.Server'
$HostSQLServiceAccount = $MSSQLServerManager.ServiceAccount;
$HostSQLServiceInstanceId = $MSSQLServerManager.ServiceInstanceId;
$HostSQLServiceName = $MSSQLServerManager.ServiceName;
$HostSQLServiceStartMode = $MSSQLServerManager.ServiceStartMode;
You can get Account, Service Start Mode, Service Name and Instance Id.
Posted in Windows Powershell | No Comment | 4,619 views | 04/02/2016 22:46
You can use [Microsoft.Win32.RegistryKey] to get remote registry values.
1
2
3
4
5
6
7
| $ComputerName = "Server";
# Create Registry Connection
$RegistryConn = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]"LocalMachine", $ComputerName)
# Get Sub Key Names
$GetSubKeyNames = $RegistryConn.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\X\").GetSubKeyNames() |
$ComputerName = "Server";
# Create Registry Connection
$RegistryConn = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]"LocalMachine", $ComputerName)
# Get Sub Key Names
$GetSubKeyNames = $RegistryConn.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\X\").GetSubKeyNames()
That will give you results.
|