Last active
March 22, 2023 20:02
-
-
Save jpomfret/3e3449146f0d72fba9654ac09472cc0f to your computer and use it in GitHub Desktop.
Get OS and SQL Version information with dbatools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$servers = Get-DbaRegServer -SqlInstance CmsServerName | |
$os = Get-DbaOperatingSystem -ComputerName $servers.name | |
$sql = Get-DbaProductKey -ComputerName $servers.name | |
$excelFile = C:\temp\VersionInfo.xlsx' | |
$osProps = 'ComputerName','Architecture','Version','Build','OSVersion', 'SPVersion', 'InstallDate','LastBootTime', 'ActivePowerPlan' | |
$sqlProps = 'ComputerName','InstanceName','SqlInstance','Version','Edition' | |
$osExcel = @{ | |
Path = $excelFile | |
WorksheetName = 'OSVersions' | |
AutoSize = $true | |
TableName = 'OSVersion' | |
IncludePivotTable = $true | |
PivotRows = 'OSVersion' | |
PivotData = @{OSVersion='Count'} | |
IncludePivotChart = $true | |
ChartType = 'ColumnClustered' | |
} | |
$os | Select-Object $osProps | export-excel @osExcel | |
$sqlExcel = @{ | |
Path = $excelFile | |
WorksheetName = 'SQLVersions' | |
AutoSize = $true | |
TableName = 'SQLVersions' | |
IncludePivotTable = $true | |
PivotRows = 'Version' | |
PivotData = @{Version='Count'} | |
IncludePivotChart = $true | |
ChartType = 'ColumnClustered' | |
} | |
$sql | Select-Object $sqlProps | export-excel @sqlExcel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In case others decide to use this, looks like single quote missing from $excelFile