top of page

PowerShell PowerCLI Create ESXi Admin  Account

    $VMHost="MyVMHostName"

    $Account="BuAdmin"

    Connect-VIServer -Protocol https -Server $VMHost -User root -Password "YourPassword"

    #Create User with Shell Access
    Write-Host "Creating User For: $Account"
       
    New-VMHostAccount -Id $Account -Password "YourNewAccountPassword" -GrantShellAccess
       
   
#Assign Administrator Permission
    $RootFolder = Get-Folder -Name ha-folder-root

    New-VIPermission -Entity $RootFolder -Principal $Account -Role Admin
    

    Disconnect-VIServer  $VMHost -Confirm:$false
        
        

PowerShell PowerCLI Review VIPermission

This was created to review current status of local accounts and
check the creation of a local backup accounts on our ESXi hosts.     

 

       $ServerName="MyVMHostName"

        #Connects to ESXi Host
        Connect-VIServer -server $Servername -Protocol https -user root -Password "MyPassword"

        #Gets a Role Permissions for account root 
        Write-Output "User Account Permissions / Role"
       Get-VIPermission -Principal root | Select Principal, Role

        #Gets a List of Roles on ESXi Host
        Write-Output "List of Permissions / Roles"
       Get-VIRole | Select Name | Format-List

        #Gets list of Local Accounts  on ESXi
        Write-Output "List of Local Accounts"
       Get-VMHostAccount | Select Name | Format-List

        Disconnect-VIServer $Servername -Confirm:$False

bottom of page