Windows – Get User Rights Assignment values in Local Computer Setting using VBScript and WMI

vbscriptwindowswindows-server-2008wmi

I'd like to get all the values of User Rights Assignment in Local Computer Setting using VBScript and WMI. Is there a way I can do this with VBScript and WMI?

Thanks.

Best Answer

Here is an example of how I did in C# .NET based on Jay Adams link and the RSOP_UserPrivilegeRight class documentation, I guess this is easily portable to VBS:

using System.Management;    

ManagementScope scope = new ManagementScope(@"\\localhost\root\rsop\computer");
ObjectQuery query = new ObjectQuery("SELECT * FROM RSOP_UserPrivilegeRight");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);

scope.Connect();

ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection)
{
    Console.WriteLine("=> User right: {0}, precedence: {1}", m["UserRight"], m["precedence"]);

    Action<string> action = new Action<string>(Console.WriteLine);
    Array.ForEach((string[])m["AccountList"], action);
 }