How to manage Hyper-V Server 2012 R2 from Windows 7 with PowerShell

hyper-v

I am tearing my hair out at the moment trying to do this. Just a couple of things to clear up:

  1. I have Windows Hyper-V Server 2012 R2 freshly downloaded and Remote Administration enabled;
  2. I have a Windows 7 Professional machine – up to date etc. etc.
  3. I know you cannot manage Hyper-V 2012 R2 from Windows 7 using the GUI, that's why I want to use PowerShell;
  4. I've been using PowerShell for a while but all this remote connection stuff is very new;

So with that out of the way, let's go.

I've used Connect-PSSession to connect to the PowerShell session on the Hyper-V server. No problem. Remote commands don't work (get-vm for example), I'm assuming because I don't have them installed locally. I tried to do import-pssession (which is what I use when I'm managing Office 365 with PS remotely) and that works but doesn't give me any hyper-v cmdlets to use. I have tried to import-module hyper-v and it doesn't exist.

So I'm stuck. I've been Googling for about 2 hours now with no luck. Plenty of very old articles about how to connect to Server 2008 ort 2012 from Windows 8 but nothing on how to connect to it from Windows 7.

Any help?

Best Answer

Do this:

  1. Create a new PSSession on your Hyper-V host
    $Session = New-PSSession -ComputerName [Hyper-V Host] -Credential (Get-Credential)
  1. then enter it:
    Enter-PSSession $Session

Your PowerShell prompt will change to indicate you're connected to the remote machine. Any powershell commands you run will be ran on the remote machine. Try it, you'll find Get-Vm now works.