VBS Script To Verify If A Specified Machine Exist In A Specified SMS Collection

 

This VBS script will allow you to enter an SMS server name and site code as well as a machine name from a series of input dialog boxes. It will then look in the collection specified and determine if the machine name exist in the collection.

 

VBS Script:

 

strComputer = InputBox ("Enter SMS Server Name")

strSiteCode = InputBox ("Enter Site Code")

strResource = InputBox ("Enter Machine Name")

 

Set objWMIService = GetObject("winmgmts://" & strComputer & "\root\sms\site_" & strSiteCode)

' SMS_CM_RES_COLL_SMS00001 Is The All Systems Collection Change As Needed

Set colItems = objWMIService.ExecQuery("Select * From SMS_CM_RES_COLL_SMS00001 Where Name ='" & strResource & "'")

 

If colItems.Count > 0 Then

MsgBox UCase(strResource) & " Exist In The Collection"

Else     

MsgBox UCase(strResource) & " Was Not Found In The Collection"

End If

 

Published Sunday, September 30, 2007 7:25 AM by dhite
Filed under:

Comments

No Comments