R2 or not R2, that is the question
Friday, May 23, 2008 at 1:00 If you want to access the OS version of a computer you've got a few options. The easiest way in PowerShell is to use the Get-QADComputer cmdlet from the excellent free set of Quest AD cmdlets. However, you'll find that you can't tell the difference between Windows Server 2003 and Windows Server 2003 R2.
In order to find out which of your servers are running R2 (if you want to audit your licences for example), you'll have to use WMI and access the OtherTypeDescription property of the Win32_OperatingSystem class. This one-liner will do the job for you (just alter the search root to match your Active Directory structure):
get-QADComputer -searchroot "yourdomain.com/servers/sql servers" | `
%{gwmi -Class win32_OperatingSystem -Namespace "root\CIMV2" -ComputerName $_.Name `
-ea silentlycontinue} | `
sort version,othertypedescription -Descending | `
ft @{label="SERVER";expression={$_.csname}},@{label="OS";expression={$_.caption}}, `
@{label="R?";expression={$_.othertypedescription}}, `
@{label="SP";expression={$_.servicepackmajorversion}} -a
What it will give you is a handy table like this:
SERVER OS R? SP
------ -- -- --
SPURS Microsoft(R) Windows(R) Server 2003, Standard Edition R2 2
PISTONS Microsoft(R) Windows(R) Server 2003, Standard Edition R2 2
LAKERS Microsoft(R) Windows(R) Server 2003 Standard x64 Edition R2 2
CELTICS Microsoft(R) Windows(R) Server 2003, Standard Edition 2
CAVS Microsoft(R) Windows(R) Server 2003, Standard Edition 2
HORNETS Microsoft(R) Windows(R) Server 2003, Standard Edition 2
Footnote:
That's fine if all of your servers are going to allow that incoming WMI query. You may have servers which are tightly locked down and you'd prefer not to open them up. If that's the case, you can do what we do and query the WMI locally on the server and write the results out to a database as part of a startup script (we currently do this in VBScript). If you take this approach, especially if you have a lot of servers, be sure to make the date part of the record so you have an idea how good it is.




Reader Comments