Hi Folks,
This is following I tried, runs fine on scvmm 2012 but not on SCVMM SP1 Beta..
Step1. set the executionpolicy unrestricted
Runspace runspacetest = RunspaceFactory.CreateRunspace();
runspacetest.Open();
Pipeline pipeline = runspacetest.CreatePipeline();
pipeline.Commands.AddScript("Set-ExecutionPolicy Unrestricted");
pipeline.Invoke();
runspacetest.Close();
Step2. importing the module "virtualmachinemanager"
InitialSessionState iss = InitialSessionState.CreateDefault();
iss.ImportPSModule(new string[] { @"virtualmachinemanager" });//importing module
Runspace runspace = RunspaceFactory.CreateRunspace(iss); //creating runspace for running further commands.
runspace.Open();
Step3. Invoking get-scvmmserver cmdlet
using (PowerShell powershell = PowerShell.Create())
{
Console.WriteLine("Going to run get-vmmserver command");
powershell.Runspace = runspace;
powershell.AddCommand("Get-VMMserver");
powershell.AddParameter("ComputerName", "localhost");
powershell.AddCommand("Out-String");
Collection<PSObject> results = powershell.Invoke();} // This is point of failure in SCVMM 2012 SP1 Beta saying it is not recognized cmdlet. But in case of SCVMM 2102 it succeeds.
Can somebody let me know
1. if any other powershell module needs to be imported apart from "virtualmachinemanager" or
2. the way i am importing module is behaving differently in SCVMM 2012 and SCVMM 2012 SP1 Beta.
3. Or Is there anything else I shall try to make this work in SCVMM 2012 SP1 Beta.