1
votes

I am collecting Resultant Set of Policies using the Group Policy Management dll. There exist a class GPRSop, which I use, with the attributes RsopMode and WMI Namspace as a string:

GPRsop test = new GPRsop(RsopMode.Logging, "Root/RSOP");
test.LoggingMode = LoggingMode.Computer;
test.LoggingComputer = "MyComputer";
test.LoggingUser = "domain\\user";
test.CreateQueryResults();
test.GenerateReportToFile(ReportType.Xml, "C:\\Temp\\test.xml");

LoggingMode, LoggingComputer and LoggingUser all throw the same exception:

System.ArgumentException: 'Value does not fall within the expected range.'

If I set the wmiNamespace " " as recommended, it also throws an exception.

1
maybe this helps: MSDN - Leon
Is CreateQueryResults getting any results? I think the error is occurring because the GenerateReportToFile() is failing do to result being empty. I would put an exception handler try/catch and get the trace stack to get more info on error. - jdweng
@jdweng GenerateReportToFile() runs successfully if CreateQueryResults() is not used. But then the report does not contain any information. - mrchelli
@jdweng Here the stack trace: at Microsoft.GroupPolicy.GPMRSOPClass.set_LoggingFlags(Int32 lVal) at Readinizer.Backend.Business.Services.ADRSoPService.getRSoP() in C:\Users\lkellenb\Documents\Readinizer\Readinizer.Backend.Business\Services\ADRSoPService.cs:line 33 at Readinizer.Frontend.ViewModels.StartUpViewModel.<Discover>b__25_0() in C:\Users\lkellenb\Documents\Readinizer\Readinizer.Frontend\ViewModels\StartUpViewModel.cs:line 64 at System.Threading.Tasks.Task.Execute() - mrchelli
See example of parameters. Note that all parameters have backslashes and you are using a forward slash : docs.microsoft.com/en-us/powershell/module/grouppolicy/… - jdweng

1 Answers

0
votes

I had to run Visual Studio as an administrator. After that I did not even need to provide a wmiNamespace.

Thanks for your help