cmd not working from c# but works fine from Windows azure powershell cmdlet

  • Thread starter Thread starter Nandiprasad Prabhu
  • Start date Start date
N

Nandiprasad Prabhu

Guest
InitialSessionState initialSessionState = InitialSessionState.CreateDefault();
initialSessionState.ImportPSModule(new string[] { @"C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1" });

Runspace runSpace = RunspaceFactory.CreateRunspace(initialSessionState);


runSpace.Open();
RunspaceInvoke runSpaceInvoker = new RunspaceInvoke( runSpace );
runSpaceInvoker.Invoke("Set-ExecutionPolicy Unrestricted");
Pipeline pipeline = runSpace.CreatePipeline();

Command import = new Command("Import-AzurePublishSettingsFile C:\\Downloads\\MyCopy.publishsettings");
pipeline.Commands.Add(import);





Import-AzurePublishSettingsFile C:\\Downloads\\MyCopy.publishsettings

This code does not work when i execute it from c# , but works fine when i execute from the powershell.

I get the exception saying the cmdlet is not found , please check the path etc

I am not able to figure out the solution , pls help

Continue reading...
 

Similar threads

C
Replies
0
Views
142
Carlo Goretti
C
C
Replies
0
Views
303
Carlo Goretti
C
U
Replies
0
Views
76
Uddipto Banerji
U
Back
Top