Vbsedit includes all these samples. Try it now!

' Retrieve Object Instance Permissions

Const adVarChar = 200
Const MaxCharacters = 255

iObjectKey = 1

On Error Resume Next
Set DataList = CreateObject("ADOR.Recordset")
With DataList.Fields
    .Append "UserName", adVarChar, MaxCharacters
    .Append "PermissionName", 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

Select Case iObjectKey
   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

Wscript.Echo "Permissions for " & strObjectKeyName & ": " + UCase(strInstanceKey)

Set colInstancePermissionNames=objSwbemServices.InstancesOf("SMS_UserInstancePermissionNames")
For Each objInstancePermissionName In colInstancePermissionNames
    If Ucase(objInstancePermissionName.InstanceKey)=Ucase(strInstanceKey) Then
        AddNewData objInstancePermissionName.UserName, objInstancePermissionName.PermissionName
    End If

Set colClassPermissionNames=objSwbemServices.InstancesOf("SMS_UserClassPermissionNames")
For Each objClassPermissionName In colClassPermissionNames
    If Ucase(objClassPermissionName.ObjectKey)=Ucase(iObjectKey) Then
        AddNewData objClassPermissionName.UserName, objClassPermissionName.PermissionName
    End If

DataList.Sort = "PermissionName"
Do Until DataList.EOF
    wscript.echo DataList.Fields.Item("PermissionName")&; " - " & DataList.Fields.Item("UserName")

Function AddNewData (UserName, Permission)
    Datalist("UserName") = UserName
    Datalist("PermissionName") = Permission
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