C# project with powershell import-module Configuration Manager -


i'm creating c# project powershell integration. working fine importing modules activedirectory.

but cannot working configuration manager, not throw , error, 'get-psdrive' result not show confmgr sitecode, in normal powershell window, other drives normal get-psdrive command.

i have tried both x64 , x86 versions of application, , without admin rigths.

can tell me problem may be?

code:

        try         {             initialsessionstate initial = initialsessionstate.createdefault();             initial.importpsmodule(new string[] { @"c:\program files (x86)\microsoft configuration manager\adminconsole\bin\configurationmanager.psd1" });             //initial.importpsmodulesfrompath(@"c:\program files (x86)\microsoft configuration manager\adminconsole\bin\configurationmanager.psd1");              runspace runspace = runspacefactory.createrunspace(initial);             runspace.open();              pipeline pipeline = runspace.createpipeline();             pipeline.commands.addscript(scripttext);             pipeline.commands.add("out-string");              collection<psobject> results = pipeline.invoke();              runspace.close();              stringbuilder stringbuilder = new stringbuilder();             foreach (psobject obj in results)             {                 stringbuilder.appendline(obj.tostring());             }              return stringbuilder.tostring();         }         catch (exception ex)         {             return ex.message;         } 

best regards thomas nissen


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -