' View an SMS Collection



On Error Resume Next

Dim objSWbemServices
Dim ProviderLoc
Dim Location
Dim colQueryCollectionResults
Dim ObjResult


Dim objQuery
Dim colQueryResults


Set ProviderLoc = GetObject _
    ("winmgmts:{impersonationLevel=impersonate}!root/sms:SMS_ProviderLocation")

If Err.Number<>0 Then
    Wscript.Echo "Couldn't get SMS Provider"
    Wscript.Quit
End If

For Each Location In ProviderLoc.Instances_
     If Location.ProviderForLocalSite = True Then
        Set objSWbemServices = GetObject("winmgmts:" & Location.NamespacePath)
        Exit For
   End If
Next


'Query Collection

Set colQueryCollectionResults=objSWbemServices.ExecQuery _
    ("SELECT * FROM SMS_FullCollectionMembership WHERE CollectionID='SMS00001'" )

If Err.Number<>0 Then
    Wscript.Echo "Couldn't get Collection"
    Wscript.Quit
End If



'run query

Wscript.Echo "Collections"
Wscript.Echo "----------------------------------"

For Each objResult In colQueryCollectionResults
    Wscript.Echo "     " + objResult.Name
Next
If colQueryCollectionResults.Count=0 Then
    Wscript.Echo "      no query results"
End If
search for scripts

VbsEdit contains all these sample scripts!


Download Now!



Download   Home   Scripts

Copyright © 2001-2024 adersοft