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
vmware:scripts:getinfo [2018/02/02 17:59] lunetikkvmware:scripts:getinfo [2018/04/24 17:51] (current) lunetikk
Line 1: Line 1:
 ====== Get infos of VMs ====== ====== Get infos of VMs ======
  
-This script need to be executed via PowerCLI+The scripts need to be executed via PowerCLI 
 + 
 +=== Full vCenter ===
  
 <code powershell vminfo.ps1> <code powershell vminfo.ps1>
Line 10: Line 12:
 $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 54:
  $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>
 +
 +=== Host CPUs ===
 +
 +<code powershell hostcpus.ps1>
 +#Remove user and pass for pass-through auth
 +Connect-VIServer -Server <HOSTNAME>
 +#Connect-VIServer -Server <HOSTNAME> -User <USERNAME> -Password <PASSWORD>
 +
 +$targetfile = "C:\Temp\HostCPUs.csv"
 +
 +get-vmhost | Select name,@{N=“# CPU“;E={($_| Get-View).Hardware.CpuInfo.NumCpuPackages}},@{N="Cores per CPU";E={($_| Get-View).Hardware.CpuInfo.NumCpuCores /($_| Get-View).Hardware.CpuInfo.NumCpuPackages}},@{N=“#Cores“;E={($_| Get-View).Hardware.CpuInfo.NumCpuCores}}| Export-csv $targetfile –NoTypeInformation
 +</code>
 +
 +
vmware/scripts/getinfo.1517590790.txt.gz · Last modified: 2018/02/02 17:59 by lunetikk