I have to keep track of our SQL Server version inventory. The goal is to reduce the SQL Server 2000 population as fast as possible.
The following PowerShell script will produce a csv file containing the database server name and the version of SQL Server it's running.
1: ## Get SQL Version installed on multiple servers ##2: ## ./sqlver.ps13: $start = get-date4: write-host "Start: " $start5: 6: [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | out-null7: 8: $FilePath = "C:\Output"9: $OutFile = Join-Path -path $FilePath -childPath ("SQLVersions_" + (get-date).toString('yyyyMMdd_hhmmtt') + ".log")10: 11: # Version inventory12: @(foreach ($svr in get-content "C:\Input\AllLOBServers.txt")13: {14: $s = New-Object "Microsoft.SqlServer.Management.Smo.Server" $svr15: $s | select Name, Version16: 17: }) | export-csv -noType $OutFile18: 19: $end = get-date 20: write-host "End: " $end21: The csv file format gives you the option of using Excel or importing to a database table for review.
PowerShell is a great way to automate simple tasks that become tedious when you need to execute that task on hundreds of servers.
Thanks Ronald , you made it so simple
ReplyDelete"Power of Knowledge"