Posted in Windows Powershell | No Comment | 998 views | 04/03/2016 14:19
You can get detailed info about SQL Server Role properties via following code:
1
2
3
4
5
6
7
8
9
10
11
| $MSSQLServerManager = New-Object 'Microsoft.SqlServer.Management.SMO.Server'
# Get SQL Roles
$MSSQLRoles = @($MSSQLServerManager.Roles)[0]
# Get SQL Logins Properties
$HostSQLRoleName = $MSSQLRoles.Name;
$HostSQLOwner = $MSSQLRoles.Owner;
$HostSQLIsFixedRole = $MSSQLRoles.IsFixedRole;
$HostSQLCreateDate = $MSSQLRoles.DateCreated;
$HostSQLDateLastModified = $MSSQLRoles.DateModified; |
$MSSQLServerManager = New-Object 'Microsoft.SqlServer.Management.SMO.Server'
# Get SQL Roles
$MSSQLRoles = @($MSSQLServerManager.Roles)[0]
# Get SQL Logins Properties
$HostSQLRoleName = $MSSQLRoles.Name;
$HostSQLOwner = $MSSQLRoles.Owner;
$HostSQLIsFixedRole = $MSSQLRoles.IsFixedRole;
$HostSQLCreateDate = $MSSQLRoles.DateCreated;
$HostSQLDateLastModified = $MSSQLRoles.DateModified;
You can also check other properties by listing all properties of $MSSQLRoles.
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.
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 | 961 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 | 583 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,667 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.
Posted in Windows Powershell | No Comment | 4,352 views | 29/01/2016 21:01
This is an example Mime Type script to show you how to get it:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| # Create Content Type Map
$ContentTypeMap = @{
".jpg" = "image/jpeg";
".jpeg" = "image/jpeg";
".gif" = "image/gif";
".png" = "image/png";
".tiff" = "image/tiff";
".zip" = "application/zip";
".json" = "application/json";
".xml" = "application/xml";
".rar" = "application/x-rar-compressed";
".gzip" = "application/x-gzip";
}
$File = Get-ChildItem C:\YourFilePath.json
$FileMimeType = $ContentTypeMap[$File.Extension.ToLower()];
Write-Output $FileMimeType |
# Create Content Type Map
$ContentTypeMap = @{
".jpg" = "image/jpeg";
".jpeg" = "image/jpeg";
".gif" = "image/gif";
".png" = "image/png";
".tiff" = "image/tiff";
".zip" = "application/zip";
".json" = "application/json";
".xml" = "application/xml";
".rar" = "application/x-rar-compressed";
".gzip" = "application/x-gzip";
}
$File = Get-ChildItem C:\YourFilePath.json
$FileMimeType = $ContentTypeMap[$File.Extension.ToLower()];
Write-Output $FileMimeType
You can get mime types from IIS.
|