' (c) Microsoft Corporation 1997-2003
'
'
' File Name:	SMS WMI.vbs
' Version:	1.0
'
'
' Release History
' 0001	-	Original	June 30, 2003

'The following line builds your WMI connection to SMS. For SERVER put in your SMS Server name.
'For XXX put in the site code for that server

winmgmt1 = "winmgmts:{impersonationLevel=impersonate}!//SERVER\root\sms\site_XXX"

'Create the connection
WScript.ECho winmgmt1
Set SystemSet = GetObject( winmgmt1 )

'Here is a query that lists Machine Name, Product, and Product Version
strQuery = "select SMS_R_System.Name,SMS_G_System_SoftwareProduct.ProductName,SMS_G_System_SoftwareProduct.ProductVersion from SMS_R_System inner join SMS_G_System_SoftwareProduct on SMS_G_System_SoftwareProduct.ResourceID = SMS_R_System.ResourceId"
Set objEnumerator = SystemSet.ExecQuery(strQuery)
for each instance in objEnumerator
WScript.Echo "-> " & instance.SMS_R_System.Name & " " & instance.SMS_G_System_SoftwareProduct.ProductName & " " & instance.SMS_G_System_SoftwareProduct.ProductVersion
Next
