Click here to Skip to main content
15,881,831 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,

I tried import module in C# with dot net version 4.5 and SCVMM 2012 r2

C#
PowerShell powershell = PowerShell.Create();
powerShell.Commands.AddCommand("Import-Module").AddParameter("Name", "virtualmachinemanager");
powerShell.Invoke(); // This throws exception.


What I have tried:

Even tried below method,

C#
InitialSessionState iss = InitialSessionState.CreateDefault();
           iss.ImportPSModule(new string[] { @"C:\vm\vm.psd1"});
           Runspace runSpace = RunspaceFactory.CreateRunspace(iss);
           runSpace.Open();


Both did not work. Please help in solving this issue in C#. Thanks in advance
Posted
Updated 20-Nov-18 7:44am
Comments
Eric Lynch 21-Nov-18 6:51am    
You may want to consider clicking "Improve question" and sharing the actual text of the exception. Beyond simply letting you know that "something" has gone wrong, the text of the exception describes that "something" and can provide clues for fixing it.

1 solution

Maybe you can try the New-SCVMCheckpoint cmdlet, New-SCVMCheckpoint | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900