Skip to content

Instantly share code, notes, and snippets.

@peterhynes
Created September 7, 2017 09:57
Show Gist options
  • Select an option

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

Select an option

Save peterhynes/dfb56ceafa71dae06896283c818394e7 to your computer and use it in GitHub Desktop.
#Script to Pull logs from ESXi host by Peter Hynes
#Version 1.0
#Created on the 03\03\2017
#Run within PowerCLI
#Script will ask for Vcenter name and hosts name
#vCenter you are working in
$vcenter = read-host "Please enter the name of the vCenter you will be working in"
#Host you are pulling logs from
$hostname = read-host "Please enter the name of the host you want to pull the logs from"
#connect to the VC
connect-viserver $vcenter
$vmhost = get-vmhost $hostname
Write-Host "Pulling logs for $vmhost...logs will open in htm format in your web browser" -foregroundcolor white
$vmhost | Get-VIEvent -MaxSamples 10000 | select createdtime, username, fullformattedmessage | ConvertTo-Html | Out-file errorreport.htm
Invoke-Expression .\errorreport.htm
Disconnect-Viserver $vcenter -confirm:$false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment