Cannot load powershell module failkoverclusters in System Center Orchestrator Runbook
When I run the sctript below it works in normal powershell on the system center orchestrator server, but not in a runbook in system center orchestrator itself. I get: "The term 'Get-Cluster' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."
To be able to load any of the modules at all I used this guide: http://tameyourcloud.com/?p=170
That took care of the "Could not load file or assembly" error I originally had, but I am now left with the error I described above here.
PowershellScripting LanguagesWindows Server 2012
Last Comment
itnifl
8/22/2022 - Mon
Hankinater
Have you tried moving the Import-Module to the top of the script?
Like this?
Import-Module 'E:\scripts\Virtual Machine Manager\bin\psModules\virtualmachinemanagercore\virtualmachinemanagercore.psd1'Import-Module 'E:\scripts\Virtual Machine Manager\bin\psModules\virtualmachinemanager\virtualmachinemanager.psd1'Import-Module 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules\FailoverClusters\FailoverClusters.psd1'Function GetFillingDegree { param([string] $ClusterName) #I have also tried just: Import-Modules FailoverClusters which works in normal powershell but not in Orchestrator $props = @{ errorlevel= 0; }
Still get the error:
"The term 'Get-Cluster' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."
Running the whole thing via powershell instead of powershell via System Center Orchestrator, and the whole thing runs nicely and returns what I would expect. But just not in Orchestrator. Obviously, Orcherstrator is not using the same environment. What is it about that? I find no guides for handeling powershell in relation to Orchestrator, but obviously, it is an issue. Maybe I am better off writing an integration pack in c#?
Hankinater
Yeah, I've had issues like that as well with Orchestrator. Most times I use Run .Net Script activity. Sometimes when I have that issue I run the script using Run Command activity and kick it off that way. The only caveat is that you get the output in one shot.
I have had some success with Execute PS Script activity, but again you'll get the output as one clump of information.
You might try having your script export it to a CSV file. You can then use that CSV in a separate PowerShell script to grab the data the way you want it.
Like this?
Open in new window