Hyper-V New-VM and Remove-VM Powershell cmdlets require Administrator privileges

If you want to script the creation of a new VM in Windows 2012 Hyper-V (and possibly Azure) using the New-VM cmdlet you have to run a Powershell session with elevated privileges (Run as Administrator) in order for the command to work even if you are already a member of the local admins group.

Running the command in a normal session will present you with the nice red error:

“You do not have permission to perform the operation or the Virtual machine Management Service is not running on the target computer or installation has been corrupted”

 Image

Perhaps more intriguing is the error you get when you try and run the Remove-VM command without Administrator privileges:

“The parameter is not valid.  Hyper-V was unable to find a virtual machine with name ……..”

 Image

It’s not that any parameter is invalid, it’s just that without Admin privileges the command can’t find the VMs.  

Annoyingly the Technet article about the New-VM command at :

http://technet.microsoft.com/en-us/library/hh848537(v=wps.620).aspx

makes no mention of needing elevated privileges to perform these commands.

It’s a fairly obvious thing to try when you see errors like this but you can still waste a chunk of time making sure that that is the real problem.

A chunk of time I’ll never get back but hopefully this will save someone else some time.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s