How to Create Local ESXi Account and Assign Permissions Using PowerCLI

Are you tired of manually creating local ESXi accounts and assigning permissions? Do you find yourself daydreaming about a simpler way to manage your ESXi hosts? Fear not, for PowerCLI is here to save the day and bring a smile to your face!

Let’s say you need to create a local account to allow a monitoring tool access to all ESXi hosts. Enter PowerCLI, the superhero of virtualization management tools.

To connect to your ESXi host, simply use the Connect-VIServer command. If you’re feeling extra adventurous and love challenges, you can even do it with your eyes closed (but we don’t recommend it).

Next, check what accounts already exist with the Get-VMHostAccount command. If you’re wondering why the script doesn’t involve a crystal ball, we’re sorry to disappoint but we haven’t discovered such a feature yet.

To create a new account, let’s make like Frankenstein and bring it to life. We can use the following command to create the account:

New-VMHostAccount -Id accountname -Password password -Description “Gruesome Account”

After creating the account, it’s time to assign the permissions. Think of it as distributing superhero capes to those most worthy. The best way to do this is by first using the Get-VIRole command to list current roles, and then assigning the role to the account using the New-VIPermission command.

New-VIPermission -Entity (Get-Folder root) -Principal accountname -Role Admin

And voila, your ESXi host is now ready to take on the world with its new account and assigned permissions – just like a spicy taco with its garnishes and hot sauce. But wait, what if you need to remove the account? Fear not, for the Get-VMHostAccount and Remove-VMHostAccount commands are here to save the day again.

Get-VMHostAccount -User accountname | Remove-VMHostAccount -Confirm:$false

With PowerCLI, managing and automating ESXi accounts and permissions is no longer a chore. You’ll be the superhero of your virtualization environment in no time. Now, who’s ready for a round of virtual high-fives?

Shout-out to TheSleepyAdmins




, ,



Leave a Reply

Your email address will not be published. Required fields are marked *