Skip to content

Instantly share code, notes, and snippets.

@peterhynes
Created November 10, 2017 14:09
Show Gist options
  • Select an option

  • Save peterhynes/80604b249ef2b3462dc9879f7aa24596 to your computer and use it in GitHub Desktop.

Select an option

Save peterhynes/80604b249ef2b3462dc9879f7aa24596 to your computer and use it in GitHub Desktop.
#Script to pull local permissions on esxi hosts
#Version 1.0
#@Peter Hynes
#Created on Nov 9th 2017
#You will need to create 3 txt files and populate them hosts.txt, vcs.txt and ilos.txt. Place these files in the same folder as this script.
#Load powercli modules
Get-Module -Name VMware* -ListAvailable | Import-Module
Add-PSSnapin vmware*
$esxihosts = get-content .\hosts.txt
$password = Read-Host "Enter root password"
ForEach ($esxihost in $esxihosts) {
Write-host "Connecting to $esxihost..." -foregroundcolor "yellow"
Connect-VIServer $esxihost -User root -Password $password
Get-VIPermission | select @{N="Host";E={Get-VMHost | select -ExpandProperty Name}}, Principal | Export-Csv -Append -Path .\hostReport.csv -UseCulture -NoTypeInformation
Disconnect-VIServer -Server $esxihost -Confirm:$False
}
Write-Host "Script complete" -foregroundcolor "yellow"
.\hostReport.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment