Hello to everyone.
I'm trying to call cmdlets from NetworkLoadBalancing from .net code but for some reason it does not work.
Code snippet 1:
InitialSesstionState iss = InitialSesstionState.CreateDefault();
iss.ImportPSModule(new string[]{@"C:\Windows\System32\WindowsPowerShell\v1.0\Modules\NetworkLoadBalancingClusters\NetworkLoadBalancingClusters.psd1"});
Runspace runspace = RunspaceFactore.Create(iss);
runspace.Open();
...
Within runspace there is an FileNotFoundException. For some other module this code snippet works.
I also tried with this code snippet 2:
PowerShell myPowerShell = PowerShell.Create();
myPowerShell.AddCommand("Import-Module").AddArgument("NetworkLoadBalancingClusters");
Collection<PSObject> results = myPowerShell.Invoke();
...
Can You please help me with this?