Vbsedit includes all these samples. Try it now!

' Retrieve User Instance Permissions

Const adVarChar = 200
Const MaxCharacters = 255


On Error Resume next
Set DataList = CreateObject("ADOR.Recordset")
With DataList.Fields
    .Append "InstanceKey", adVarChar, MaxCharacters
    .Append "PermissionName", adVarChar, MaxCharacters
    .Append "ObjectKeyName", adVarChar, MaxCharacters
End With

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

If err.number<;>;0 Then
    wscript.echo "Couldn't Get SMS Provider"
End If

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

Wscript.Echo "Instance permissions for " + UCase(strUser)

Set colClassPermissionNames=objSwbemServices.InstancesOf("SMS_UserClassPermissionNames")
For Each objClassPermissionName In colClassPermissionNames
    If Ucase(objClassPermissionName.UserName)=Ucase(strUser) Then
        strInstanceKey = "All Instances"
        AddNewData strInstanceKey, objClassPermissionName.ObjectKey, _
    End If
Set colInstancePermissionNames=objSwbemServices.InstancesOf("SMS_UserInstancePermissionNames")
For Each objInstancePermissionName In colInstancePermissionNames
    If Ucase(objInstancePermissionName.UserName)=Ucase(strUser) Then
        AddNewData objInstancePermissionName.InstanceKey, objInstancePermissionName.ObjectKey, _
    End If

DataList.Sort = "ObjectKeyName"

Do Until DataList.EOF
    wscript.echo Datalist.Fields.Item("ObjectKeyName") & " - " & DataList.Fields.Item("InstanceKey")_
        & " - " & DataList.Fields.Item("PermissionName")

Function AddNewData (InstanceKey, ObjectKey, Permission)
    Datalist("InstanceKey") = InstanceKey
    Datalist("PermissionName") = Permission
    Select Case ObjectKey
        Case 1 strObjectKeyName = "Collection"            
        Case 2 strObjectKeyName = "Package"
        Case 3 strObjectKeyName = "Advertisement"
        Case 4 strObjectKeyName = "Status Message"
        Case 6 strObjectKeyName = "Site" 'ObjectKey #5 is unused
        Case 7 strObjectKeyName = "Query"
        Case 8 strObjectKeyName = "Report"
        Case 9 strObjectKeyName = "Software Metering Rule"
        Case 10 strObjectKeyName = "Software Updates"
    End Select
    Datalist("ObjectKeyName") = strObjectKeyName
End Function


search for scripts

VbsEdit includes all these samples!

VbsEdit now supports .vbs, .js, .wsf and .hta scripts.
The evaluation version never expires.

Home   Scripts

Copyright © 2001-2019 adersοft