Tome's Land of IT

IT Notes from the Powertoe – Tome Tanasovski

Powerbits #8 – Opening a Hyper-V Console From PowerShell

I am right now Windows Server 8 and PowerShell 3 Beta obsessed.  I want to blog – I want to blog – I want to blog, but I’m trying to hold back a lot of it until we see how everything shakes out.  I’m running Serer 8 beta on my new Asus ultrabook.  Because of this, I’m also running a ton of Hyper-V VMs on my fancy type-1 hypervisor in order to play with the new features in PowerShell 3 such as PowerShell Web Access and disconnected PSSessions.  I love the autoload of the Hyper-V module when I do something like Get-VM, but I was really disappointed that there was no cmdlet to open up a console session for one of my VMs.  I mean, I have no interest in loading up a GUI for Hyper-V to do this.  A bit of quick research led me to vmconnect.exe.

So, without further ado, here’s a quick wrapper that will let you open up Hyper-V console sessions directly from PowerShell.  This is now permanently in my profile:

function Connect-VM {
		foreach ($name in $computername) {
			vmconnect localhost $name

Now, you can either do something like

Connect-VM server2



Finally, if you are running PowerShell 3.0, you can do the following:

(get-vm).name |Connect-VM

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: