This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| vmware:scripts:getinfo [2018/01/29 12:28] – created lunetikk | vmware:scripts:getinfo [2018/04/24 17:51] (current) – lunetikk | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Get infos of VMs ====== | ====== Get infos of VMs ====== | ||
| - | This script | + | The scripts |
| + | |||
| + | === Full vCenter === | ||
| <code powershell vminfo.ps1> | <code powershell vminfo.ps1> | ||
| #Remove user and pass for pass-through auth | #Remove user and pass for pass-through auth | ||
| Connect-VIServer -Server < | Connect-VIServer -Server < | ||
| + | # | ||
| + | |||
| $allvminfo = @() | $allvminfo = @() | ||
| $vms = Get-Vm | $vms = Get-Vm | ||
| + | $targetfile = " | ||
| foreach($vm in $vms){ | foreach($vm in $vms){ | ||
| - | $vminfo = "" | + | $vminfo = "" |
| - | $VMHost = Get-VM $vm.Name | select Host | + | $VMHost = Get-VMHost |
| $VMHost = $VMHost.Host | $VMHost = $VMHost.Host | ||
| $VMNetwork = Get-VM $vm.Name | Select {@($_.guest.IPAddress[0])} | $VMNetwork = Get-VM $vm.Name | Select {@($_.guest.IPAddress[0])} | ||
| - | $VMNetwork = $VMNetwork.Network | ||
| $VMPowerState = Get-VM $vm.Name | select PowerState | $VMPowerState = Get-VM $vm.Name | select PowerState | ||
| $VMPowerState = $VmPowerState.PowerState | $VMPowerState = $VmPowerState.PowerState | ||
| Line 34: | Line 38: | ||
| $ProvisionedSpace =$ProvisionedSpace.ToString() | $ProvisionedSpace =$ProvisionedSpace.ToString() | ||
| $ProvisionedSpace = $ProvisionedSpace + " GB" | $ProvisionedSpace = $ProvisionedSpace + " GB" | ||
| + | $ConfiguredOS = Get-VM $vm.Name | Select {@($_.ExtensionData.Config.GuestFullname)} | ||
| + | $RunningOS = Get-VM $vm.Name | Select {@($_.Guest.OsFullName)} | ||
| $vminfo.Name = $vm.Name | $vminfo.Name = $vm.Name | ||
| Line 45: | Line 50: | ||
| $vminfo.UsedSpace = $UsedSpace | $vminfo.UsedSpace = $UsedSpace | ||
| $vminfo.UnUsedSpace = $UnUsedSpace | $vminfo.UnUsedSpace = $UnUsedSpace | ||
| + | $vminfo.ConfiguredOS = $ConfiguredOS | ||
| + | $vminfo.RunningOS = $RunningOS | ||
| $allvminfo += $vminfo | $allvminfo += $vminfo | ||
| } | } | ||
| - | $allvminfo | Select Name, Host, Network, PowerState, CPUCount, RAMAssigned, | + | $allvminfo | Select Name, Host, Network, PowerState, CPUCount, RAMAssigned, |
| + | |||
| + | #The following lines will clean up the .csv | ||
| + | (Get-Content $targetfile).replace(' | ||
| + | (Get-Content $targetfile).replace(' | ||
| + | (Get-Content $targetfile).replace(' | ||
| + | (Get-Content $targetfile).replace(' | ||
| </ | </ | ||
| + | |||
| + | === Host CPUs === | ||
| + | |||
| + | <code powershell hostcpus.ps1> | ||
| + | #Remove user and pass for pass-through auth | ||
| + | Connect-VIServer -Server < | ||
| + | # | ||
| + | |||
| + | $targetfile = " | ||
| + | |||
| + | get-vmhost | Select name, | ||
| + | </ | ||
| + | |||
| + | |||