I have a powershell script that I'm attempting to execute over SSH. The command works perfectly when I run it from the server's powershell commandline.

Here is my Powershell script:


$vms = Get-ClusterResource | Where-Object{$_.ResourceType -like "Virtual Machine"}

foreach ($vm in $vms)
    if ($vm -eq "Virtual Machine server-name")
        Echo "Stop $vm"
        Stop-ClusterGroup $vm.OwnerGroup

Here is the command that I am executing:

C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe -file "C:\Scripts\VMShutDown.ps1"

However, when I run this from a remote machine (Ubuntu 12.04). I get the following error:

Get-ClusterResource : The term 'Get-ClusterResource' 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.

Any thoughts to what I might be doing wrong?

Operating Systems:

Windows Server 2012 Standard - 64 Bit Operating System

Ubuntu 12.04.4 LTS

  • Check the users' PATH variable. Make sure it matches the same path displayed when logged on locally. – Lars Aug 1 '14 at 19:27
  • The first thought that comes to mind is that the relevant module might not be getting loaded when you're executing over SSH. Does import-module failoverclusters before the Get-ClusterResource cmdlet solve your woes? – HopelessN00b Aug 1 '14 at 19:43
  • Interesting, when I do the import-module failoverclusters, I get a no valid module file was found in any module directory. This also works local to the machine. – CodeLikeBeaker Aug 1 '14 at 19:47


Remote power shell executes 32 bit power shell, even on a 64 bit machine. This causes issues loading modules that are only installed and able to be executed using 64 bit process (Failover Clustering for example)

Solution: Create a 64 bit wrapper and execution process.

I created a .bat file which executed the ps1 script from the command line:

powershell.exe -file "C:\{path}\{first-file}.ps1"

Inside this script, you have to create an alias to point to the native 64 bit executable for powershell:

Set-Alias ps64 "$env:windir\sysnative\WindowsPowerShell\v1.0\powershell.exe"

Once you do this, you can execute another file from within this file:

ps64 {C:\{path}\{second-file}.ps1}

Here, it will load all the proper modules, and execute your 64 bit script.

After doing that, I was able to execute my PS command from Linux and it worked like a charm.

Reference to solution:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.