Created
April 6, 2016 21:18
-
-
Save omniproc/7b6309c6238abfae8bb0ac8330324941 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Set-PowerCLIConfiguration -InvalidCertificateAction Ignore | |
$vcenterServer = YOUR_VCENTER_SERVER_FQDN | |
$cluster = YOUR_VCENTER_CLUSTER | |
$esxiUser = "root" | |
$esxiPass = "YourMama" | |
$newUserName = "NameOfTheUserYouWantToAdd" | |
$newUserDomain = "DomainNameOfTheUserYouWantToAdd" | |
Try | |
{ | |
Connect-VIServer -Server $vcenterServer | |
$esxlist = Get-Cluster $cluster | Get-VMHost | |
foreach($esx in $esxlist) | |
{ | |
Connect-VIServer -Server $esx.Name -User $esxiUser -Password $esxiPass | |
New-VIPermission ` | |
-Entity (Get-Folder -NoRecursion -Server $esx.Name) ` | |
-Principal (Get-VIAccount -Domain $newUserDomain -User $newUserName -Server $esx.Name) ` | |
-Propagate $true ` | |
-Role (Get-VIRole -Name ReadOnly -Server $esx.Name) | |
Disconnect-VIServer -Confirm:$false -Server $esx.Name | |
} | |
Disconnect-VIServer -Confirm:$false * | |
} | |
Catch | |
{ | |
Disconnect-VIServer -Confirm:$false * | |
Write-Host "Error occured while processing. Exit." | |
} | |
#Get-VIPermission -Principal (Get-VIAccount -Domain $newUserDomain -User $newUserName ) | select-object * | |
#Remove-VIPermission -Permission (Get-VIPermission -Principal (Get-VIAccount -Domain $newUserDomain -User $newUserName )) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adds a Active Directory user as local user to all ESXi hosts within a vCenter cluster and assigns it read-only permissions. Usefull if Active Directory based authentication has been enabled within a cluster and local users need to be added, e.g. for monitoring services.