Hi all,
I’m battling a bit with PowerShell… ?
I have written the following scripts – One for SQL 2012 and the other for SQL 2014
The bit I’m struggling with is to get the memory allocated to that server hosting the SQL instance
The memory can be called from the following class:-
get-scomclass -name ‘Microsoft.Windows.Server.OperatingSystem’
Script 1
$SQLDBs=get-scomclass -name “microsoft.sqlserver.2012.dbengine”| get-scomclassinstance foreach($SQLDB in $SQLDBs) { Get-SCOMClass –Name Microsoft.Windows.Computer | Get-SCOMClassInstance | Select displayname, @{Label=”Computer”;Expression= {$_.’[Microsoft.Windows.Computer].NetbiosComputerName’}}, @{Label=”IPAddress”;Expression= {$_.’[Microsoft.Windows.Computer].IPAddress’}}, @{Label=”Instance”;Expression= {$SQLDB.’[Microsoft.SQLServer.Serverrole].InstanceName’}}, @{Label=”ConnectionString”;Expression= {$SQLDB.’[Microsoft.SQLServer.DBEngine].ConnectionString’}}, @{Label=”Version”;Expression= {$SQLDB.’[Microsoft.SQLServer.DBEngine].Version’}}, @{Label=”SPVersion”;Expression= {$SQLDB.’[[Microsoft.SQLServer.DBEngine].ServicePackVersion’}}, @{Label=”Edition”;Expression= {$SQLDB.’[Microsoft.SQLServer.DBEngine].Edition’}}, @{Label=”AuthMode”;Expression= {$SQLDB.’[Microsoft.SQLServer.DBEngine].AuthenticationMode’}}, @{Label=”Cluster”;Expression= {$SQLDB.’[Microsoft.SQLServer.DBEngine].Cluster’}}, @{Label=”DomainName”;Expression= {$_.’[Microsoft.Windows.Computer].NetbiosDomainName’}}, @{Label=”VirtualMachine?”;Expression= {$_.’[Microsoft.Windows.Computer].IsVirtualMachine’}}, @{Label=”AD Site”;Expression= {$_.’[Microsoft.Windows.Computer].ActiveDirectorySite’}}, @{Label=”LogicalProcessors”;Expression= {$_.’[Microsoft.Windows.Computer].LogicalProcessors’}}, @{Label=”PhysicalProcessor”;Expression= {$_.’[Microsoft.Windows.Computer].PhysicalProcessors’}} | where-object{$_.displayname -eq $SQLDB.path} |export-csv C:\Users\schoemana\Desktop\SQL\SQLVersion\SQLServer2012DBEngineGroup.csv -append }
Script 2
$SQLDBs=get-scomclass -name “microsoft.sqlserver.2014.dbengine”| get-scomclassinstance foreach($SQLDB in $SQLDBs) { Get-SCOMClass –Name Microsoft.Windows.Computer | Get-SCOMClassInstance | Select displayname, @{Label=”Computer”;Expression= {$_.’[Microsoft.Windows.Computer].NetbiosComputerName’}}, @{Label=”IPAddress”;Expression= {$_.’[Microsoft.Windows.Computer].IPAddress’}}, @{Label=”Instance”;Expression= {$SQLDB.’[Microsoft.SQLServer.2014.Serverrole].instanceName’}}, @{Label=”ConnectionString”;Expression= {$SQLDB.’[Microsoft.SQLServer.2014.DBEngine].ConnectionString’}}, @{Label=”Version”;Expression= {$SQLDB.’[Microsoft.SQLServer.2014.DBEngine].version’}}, @{Label=”Edition”;Expression= {$SQLDB.’[Microsoft.SQLServer.2014.DBEngine].edition’}}, @{Label=”SPVersion”;Expression= {$SQLDB.’[Microsoft.SQLServer.2014.DBEngine].ServicePackVersion’}}, @{Label=”AuthMode”;Expression= {$SQLDB.’[Microsoft.SQLServer.2014.DBEngine].AuthenticationMode’}}, @{Label=”Cluster”;Expression= {$SQLDB.’[Microsoft.SQLServer.2014.DBEngine].Cluster’}}, @{Label=”DomainName”;Expression= {$_.’[Microsoft.Windows.Computer].NetbiosDomainName’}}, @{Label=”VirtualMachine?”;Expression= {$_.’[Microsoft.Windows.Computer].IsVirtualMachine’}}, @{Label=”AD Site”;Expression= {$_.’[Microsoft.Windows.Computer].ActiveDirectorySite’}}, @{Label=”LogicalProcessors”;Expression= {$_.’[Microsoft.Windows.Computer].LogicalProcessors’}}, @{Label=”PhysicalProcessor”;Expression= {$_.’[Microsoft.Windows.Computer].PhysicalProcessors’}} | where-object{$_.displayname -eq $SQLDB.path} |export-csv C:\Users\schoemana\Desktop\SQL\SQLVersion\SQLServer2014DBEngineGroup.csv -append }