Site Tools


vmware:scripts:getinfo

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
vmware:scripts:getinfo [2018/02/02 17:59] lunetikkvmware:scripts:getinfo [2018/04/23 17:53] lunetikk
Line 10: Line 10:
 $allvminfo = @() $allvminfo = @()
 $vms = Get-Vm $vms = Get-Vm
 +$targetfile = "C:\Temp\VMInfo.csv"
  
 foreach($vm in $vms){ foreach($vm in $vms){
 $vminfo = "" | Select Name, Host, Network, PowerState, CPUCount, RAMAssigned, ProvisionedSpace, UsedSpace, UnusedSpace, ConfiguredOS, RunningOS $vminfo = "" | Select Name, Host, Network, PowerState, CPUCount, RAMAssigned, ProvisionedSpace, UsedSpace, UnusedSpace, ConfiguredOS, RunningOS
-$VMHost = Get-VM $vm.Name | select Host +$VMHost = Get-VMHost -VM $vm 
 $VMHost = $VMHost.Host  $VMHost = $VMHost.Host 
 $VMNetwork = Get-VM $vm.Name | Select {@($_.guest.IPAddress[0])} $VMNetwork = Get-VM $vm.Name | Select {@($_.guest.IPAddress[0])}
Line 51: Line 52:
  $allvminfo += $vminfo  $allvminfo += $vminfo
 } }
-$allvminfo | Select Name, Host, Network, PowerState, CPUCount, RAMAssigned, ProvisionedSpace, UsedSpace, UnusedSpace, ConfiguredOS, RunningOS | Export-Csv "C:\Temp\VMinfos.csv" -noTypeInformation+$allvminfo | Select Name, Host, Network, PowerState, CPUCount, RAMAssigned, ProvisionedSpace, UsedSpace, UnusedSpace, ConfiguredOS, RunningOS | Export-Csv $targetfile -noTypeInformation 
 + 
 +#The following lines will clean up the .csv 
 +(Get-Content $targetfile).replace('@{@($_.guest.IPAddress[0])=', '') | Set-Content $targetfile 
 +(Get-Content $targetfile).replace('@{@($_.ExtensionData.Config.GuestFullname)=', '') | Set-Content $targetfile 
 +(Get-Content $targetfile).replace('@{@($_.Guest.OsFullName)=', '') | Set-Content $targetfile 
 +(Get-Content $targetfile).replace('}"', '"') | Set-Content $targetfile
 </code> </code>
vmware/scripts/getinfo.txt · Last modified: 2018/04/24 17:51 by lunetikk