Cloud

A:-Get-Cluster “CLNAME” | Get-VM |

B:-Get-VIEvent |

C:-where {$_.FullFormattedMessage -match “vSphere HA restarted virtual machine”} |

D:-select ObjectName,@{N=”IP addr”;E={(Get-view -Id $_.Vm.Vm).Guest.IpAddress}},CreatedTime,FullFormattedMessage | Export-Csv c:\Temp\restartedvmbyha.csv

Note:- To check restarted VM by HA agent when esxi host PSOD error, above syntax should be in Notepad++ 7 lines.
————————————————————
To find missed datastores to the esxi host in the cluster ?
Few of the datastore is not added to the esxi host ? check zoning is that LUN id configured to the missed esxi HBA ?
below is the syntax copy 45 lines into Notepad++ to check missed datastores.
$esxName = get-content c:\temp\listserver.txt

$dsTab = @{}

foreach($ds in (Get-Datastore -VMHost $esxName | where {$_.Type -eq “vmfs”})){

$ds.Extensiondata.Info.Vmfs.Extent | %{

$dsTab[$_.DiskName] = $ds.Name

}

}

$report = @()

Get-ScsiLun -VmHost $esxName -LunType “disk” | %{

$hostid = $_.VMHostID

$hostsrv = get-vmhost -id $hostid

$row = “” | Select Host, ConsoleDeviceName, Vendor, Model, Datastore

$row.host = $hostsrv.Name

$row.ConsoleDeviceName = $_.ConsoleDeviceName

$row.vendor = $_.Vendor

$row.model = $_.Model

$row.Datastore = &{

if($dsTab.ContainsKey($_.CanonicalName)){

$dsTab[$_.CanonicalName]

}

}

$report += $row}

$report |Export-Csv c:\Temp\vegresults112.csv -NoTypeInformatio