Adding yourself to the Hyper-V Administrators group with PowerShell

I am currently setting up a couple of new computers – and thought I would share this little tidbit of information.  As I have  blogged in the past, you do not need to run “As Administrator” to use Hyper-V PowerShell cmdlets.  You just have to be a member of the Hyper-V Administrators group.

Well – you can also use PowerShell to add yourself to the local Hyper-V administrators group, with this simple one-liner:

([adsi]"WinNT://./Hyper-V Administrators,group").Add("WinNT://$env:UserDomain/$env:Username,user")

A couple of points to make:

  1. You do need to run PowerShell “As Administrator” to run this one command – but after that point you can happily use Hyper-V without elevation.
  2. You will need to log out and log back in for this change to take effect.

Cheers,
Ben