Wait…You Can Invoke-Command directly to a Hyper-V VM? This Changes so Many Things.

Why yes, yes you can, and it’s called Powershell Direct . I had no idea was a thing until we decided we were going to switch some of our VMware stack over to Hyper-V.

The gist of it is, instead of having to go through the whole process of enabling WinRM on your VMs, whether they are server or desktop VMs, then using the typical Enter-PSSession -Computername <name>, or Invoke-Command -computername <name> -Scriptblock <code>.

You can simply run commands directly from your Hyper-V host like so:

1
Invoke-Command  -VMName <virtual machine name> -ScriptBlock {<commands to execute  remotely>}

or

1
Enter-PSSession -VMName <virtual machine name>

That’s it.

What I’m imagining is this will make automating some tasks much easier by just executing them directly on the Hyper-V host. Something that could not be done as easily on our current VSphere stack.

Man I wish I had known about this a long time ago. I would have moved more of our stack sooner to Hyper-V.

Thanks for reading, and don’t laugh to much at me for being so excited about something so simple. 😛

Leave a Reply

Your email address will not be published. Required fields are marked *