Cum sa identifici versiunea de Windows din WMI

By Andrei Ungureanu - Last updated: Tuesday, June 7, 2011 - Save & Share - Leave a Comment

Cateodata e necesar sa identifici versiunea de Windows pe care vrei sa ruleze un anumit script, fie ca sunt logon script-uri, fie ca le rulezi manual si ar fi dificil sa cautam intr-un string de caractere cuvinte gen “server”, “XP” sau “Vista”.

Pentru asta ne putem folosi de version number si producttype pe care le putem obtine via WMI:

Version Number:

Windows Server 2008 R2 or Windows 7  –  6.1%

Windows Server 2008 or Windows Vista  –  6.0%

Windows Server 2003  –  5.2%

Windows XP  –  5.1%

Windows 2000  –  5.0%

Product Type:

Windows Server 2008 R2 or Windows 7  – 6.1%

Windows Server 2008 or Windows Vista  –  6.0%

Windows Server 2003  –  5.2%

Windows XP  –  5.1%

Windows 2000  –  5.0%

http://technet.microsoft.com/en-us/library/cc754488(WS.10).aspx

Iar lucrul asta poate fi foarte util atunci cand vrem sa limitam aplicarea unor GPO-uri doar la anumite OS-uri:

image

image

image

Sau daca vrem doar sa influentam modul in care ruleaza un script iata un exemplu care citeste versiunea si tipul OS-ului:

strComputer = “.”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)

Set colOperatingSystems = objWMIService.ExecQuery _
(“Select * from Win32_OperatingSystem”)

For Each objOperatingSystem in colOperatingSystems
Wscript.Echo objOperatingSystem.Caption & ” ” & _
objOperatingSystem.Version & ”    ” & objOperatingSystem.ProductType

Next

 

Restul tine doar de imaginatia voastra. Pentru alte detalii ma gasiti pe forum.

Posted in Active Directory, Scripting, Uncategorized • Tags: , , , Top Of Page

Write a comment