Managing VMware ESXi Local User Accounts with PowerCLI
As a VMware vSphere administrator, managing local user accounts on VMware ESXi hosts can be a time-consuming task, especially when done manually. However, using VMware PowerCLI, you can easily modify these accounts and perform other management tasks remotely. In this blog post, we will cover how to list all local user accounts, create a new user account, update an existing user account, and delete a user account using PowerCLI.
Listing All Local User Accounts
To list all local user accounts on a VMware ESXi host, you can use the following command:
“`
$esxcli.system.account.list.Invoke()
“`
This command will return an output similar to the following:
“`
Id Name Description ShellAccess
— ———————- ———– ———-
1 root System Account True
2 myUser My New User Account False
“`
As you can see, the output lists all local user accounts on the host, including the id, name, description, and shell access.
Creating a New Local User Account
To create a new local user account, we can use the following command:
“`
$esxcli.system.account.add.CreateArgs = @{
Id = “myNewUser”
Name = “My New User Account”
Description = “A new user account created with PowerCLI”
ShellAccess = $false
}
$esxcli.system.account.add.Invoke()
“`
This command creates a new local user account with the specified id, name, description, and shell access. The output will be similar to the following:
“`
True
“`
As you can see, the output indicates that the account was successfully created.
Updating an Existing Local User Account
To update an existing local user account, we can use the following command:
“`
$esxcli.system.account.set.CreateArgs = @{
Id = “myUser”
Name = “My New User Account”
Description = “A new description for myUser”
ShellAccess = $false
}
$esxcli.system.account.set.Invoke()
“`
This command updates the specified local user account with the new values provided. The output will be similar to the following:
“`
True
“`
As you can see, the output indicates that the account was successfully updated.
Deleting a Local User Account
To delete a local user account, we can use the following command:
“`
$esxcli.system.account.remove.CreateArgs = @{
Id = “myUser”
}
$esxcli.system.account.remove.Invoke()
“`
This command deletes the specified local user account. The output will be similar to the following:
“`
True
“`
As you can see, the output indicates that the account was successfully deleted.
Conclusion
In this blog post, we have covered how to list all local user accounts, create a new local user account, update an existing local user account, and delete a local user account using PowerCLI. These tasks can be time-consuming when done manually, but with PowerCLI, you can perform these tasks quickly and easily. Be sure to check out my other blog posts for more information on managing VMware ESXi hosts with PowerCLI.