Take the 2-minute tour ×

Im basically wondering if this is possible, Essentially I have a Powershell 3.0 Script that creates a Hyper-V Server/VHD etc.. it works well but it's obviously defaulting to my local machine.

What Im wondering is that if it's possible to make perhaps remote VHD's/VM's through powershell. Like Accessing another computer/server on a network and deploy the VM/VHD through Powershell on A Central Computer?

I looked around the Hyper-V cmdlets....but couldn't really find anything, I know you define Paths and such for VHD storage....and File storage and such, but creating the VM doesn't seem to have any parameters to allow remote control. Since ideally I would want to be able to deploy a VM and attach it to a pre-baked VHD via remote to another server/computer. Also the VHD's are being created on my Local Computer right now, is there a way to create them to a linked network server perhaps?

share|improve this question
add comment

1 Answer

What you're looking for is PowerShell Remoting. This lets you connect to a remote machine and run PowerShell commands like you're remoted in to that computer. It's similar to telnet/ssh in to a Linux box.

The simplest form is Enter-PSSession followed by the remote server name. This simply opens an interactive PowerShell session to the remote server. Any commands you enter now will be executed on the remote server.

Another simple form is Invoke-Command, which allows you to remotely execute PowerShell scripts using the -FilePath option. The path to the script should be a local path. You can even execute the same script simultaneously on multiple servers by passing an array of server names instead of just one server name.

share|improve this answer
Ok that makes sense, but what I perhaps be able to create VHD's on ANOTHER server by redoing the path...or something if I were to run powershell like on my computer here. Could I create a vhd somewhere else that way? Or would I have to do ALL of it remotely? –  Mercfh Mar 7 '13 at 21:30
Theoretically you could. But that's a horribly inefficient way of doing it because your computer would be writing the VHD over the network. If you want the remote server to handle the creation for you, then you need to use remoting. –  longneck Mar 7 '13 at 21:38
That makes sense, I didn't think about that.......Hmmm good point this is more for a job "given" to me, but pretending that I just HAD to do it the inefficient way....what would I have to modify? or would I literally just retype the paths pointing to a server (like \\server01\whatever) when creating a VHD for instance? –  Mercfh Mar 7 '13 at 21:47
And besides, why would Microsoft implement a PowerShell command that instructs a remote server to create a VHD? There's no need because PowerShell already supports sending commands to a remote server natively. No need to reinvent the wheel! –  longneck Mar 7 '13 at 21:51
nothing special –  longneck Mar 7 '13 at 22:46
show 1 more comment

Your Answer


