Powercli – Audit Script VMware (State,CPU,Size,@mac,IP,etc..)

Ce message est également disponible en : French

This is a script that will audited your VMware infrastructure.

For example, the script can be usefull if you will migrate your VMware infrastructure.

You will be able to retrieve these informations :

– State
– Name
– CPU
– Memory
– IPAddress
– OSFullName
– Cluster
– Directory
– UsedspaceGB
– Datastore
– Description
– MacAddress
– Path
– NetworkName
– NetworkAdapter

—————————————————-

$AuditVM = @()
ForEach ($vm in (Get-Cluster | Get-VM )) {
foreach ($vmguest in @($vm | Get-VMguest)) {
foreach ($cluster in @($vm | Get-Cluster )) {
foreach ($datastore in @(Get-VM $vm | Get-Datastore)) {
foreach ($Network in @(Get-VM $vm | Get-NetworkAdapter)) {
$objGuest= “” | Select State, Name,CPU, Memory, IPAddress, OSFullName, Cluster, Folder, UsedspaceGB, Datastore, Description, MacAddress, Path, NetworkName, NetworkAdapter
$objGuest.State= $vmguest.state
$objGuest.CPU = $vm.NumCPU
$objGuest.Memory = $vm.MemoryMB
$objGuest.Description= $vm.Notes
$objGuest.Folder=$vm.Folder
$objGuest.Name = $vm.Name
$objGuest.IPAddress = [string]::Join(‘,’,$vmguest.IPAddress)
$objGuest.OSFullName = $vmguest.OSFullName
$objGuest.UsedSpaceGb = $vm.UsedSpaceGB
$objGuest.Cluster = $cluster.Name
$objGuest.Datastore = $datastore.Name
$objGuest.MacAddress = $Network.MacAddress
$objGuest.Path = $vm.Extensiondata.Config.Files.VmPathName
$objGuest.NetworkName = $Network.NetworkName
$objGuest.NetworkAdapter = $Network.Name
$AuditVM += $objGuest
}
}
}
}
}

$AuditVM | Export-Csv d:\auditvm.csv -noTypeInformation | Format-Table -AutoSize # Replace d:\auditvm.csv with your path

———————————————————————————

Follow me

Julien Varela

Sr . Systems Engineer at Nutanix
and blogger @vThink.
Follow me

Leave a Reply