Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Dot Net 4.0 application for powershell fails to execute on Windows Server 2008 R2

$
0
0
  • I have a x64 dot net console application, to execute powershell cmdlets for Failoverclusters module.
  • I've compiled application with .Net 4.0.
  • Here DotNet4.5 is already installed. I tried to execute this application on windows server 2012.  FailoverClusters module loaded successfully on Windows Server 2012 and all cmdlets executed successfully
  • Now I installed dotnet 4.5 on Windows Server 2008 R2, and tried to execute application. It does not execute any of failovercluster cmdlet (FOC is configured). It executes default cmdlets like Get-ChilItem, Get-Process.
  • Below is code i've used in my program

Runspace rSpace;
InitialSessionState SessionState;
RunspaceInvoke invoker;
string[] strImportModules = new[] { "FailoverClusters" };

SessionState = InitialSessionState.CreateDefault();
SessionState.ImportPSModule(strImportModules);
rSpace = RunspaceFactory.CreateRunspace(SessionState);
rSpace.Open();
invoker = new RunspaceInvoke(rSpace);

Collection<PSObject> results = m_invoker.Invoke(script, null, out m_errors);

//Here script is Failovercluster cmdlet can be like "Get-Cluster", "Get-clusterNode", "Get-clusterNode"


Bharat


Viewing all articles
Browse latest Browse all 21975

Trending Articles