Delen via


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

Comments

  • Anonymous
    May 30, 2016
    Hey Ben. Since Windows 10 allows you to log in to the computer with your Office 365/Azure AD login ID, would this PowerShell work? I had problems putting users who log in using Azure AD to their computers (and made local admin) be put into the HyperV admin. Wondering if there's a way for that?
    • Anonymous
      May 30, 2016
      I just ran this code on a computer where I was logged in with my live ID - so I would assume that it would work with Azure AD - but I have not tried it out.
  • Anonymous
    May 30, 2016
    Very nice, Ben. I knew how to do this, but putting it in a single, user-independent, one-liner is slick. And going into my toolchest!Note, however, that this one-liner will not work as-is if you aren't actually running as an account with admin privileges. If you normally run as a limited user account (which I do), you'll need to open a PowerShell window with an account that does have admin privs and use a user-specific variant of this command to grant your non-admin user the rights to run Hyper-V.
    • Anonymous
      May 30, 2016
      Good point!
  • Anonymous
    June 06, 2016
    A este lugar vou proferir relativamente fundamental concernente a Guitarra, a partir de dicas desde instrução, equipamentos,notícias dentre criados Guitarristas, etc.
  • Anonymous
    June 12, 2016
    The comment has been removed
  • Anonymous
    June 13, 2016
    Hi Ben. This is very nice but I'm still having a problem, that there is NO Hyper-V Administrators group on Windows 10 Enterprise 2015 LTSB which makes managing Hyper-V for non-administrators virtually impossible. Is there any solution to that issue yet? My ticket with Microsoft has been closed without any reason saying that "Yes, this is a known bug and no, we can't do anything about it..". Thanks.
    • Anonymous
      August 01, 2016
      I run into the same issue. Basically I can not use Android Emulator with Visual Studio 2015 Professional cause the Hyper-V Administrators group does not exist on my machine. It's very frustrating. Any solution?
  • Anonymous
    July 15, 2016
    Your wefding can be a personal event in your lives & should reflect your likes, personalities & style. Wedding Planning Checklists also help youu to be a timeline and may shpw you when you should send out of thee save the date cards, invitations etc. Then you will find the cost from the honeymoon to consider.
  • Anonymous
    July 22, 2017
    You should come to Michigan where they don't seem to be paid for by anything and it shows in the quality and