Skip to content

VirtuallyThatGuy

Anything VMware , PowerCLI, PowerShell, Automation and some Windows

Menu
  • Home
  • PowerCLI
  • VMware
  • Automation
  • Windows
  • About
Menu

VM disk space usage, Get-VM or VMhost LOGS, VM Snapshot Report to CSV – Using Powercli – Virtually That Guy

Posted on 8 November 20196 December 2022 by VirtuallyThatGuy

VM disk space usage

[math]::Round(((get-vm | Where-object{$_.PowerState -eq "PoweredOn" }).UsedSpaceGB | measure-Object -Sum).Sum)

 

Check VM and VMtools level  

get-vm | where-object {$_.GuestFullName -like “*Linux*”} | select Name,GuestFullName,ToolsVersionStatus,ToolsVersion | FT -a

 

Check VM and VMtools level and include the Ones that require tools only

 

get-vm​​ |​​ where-object​​ {$_.GuestFullName​​ -like​​ “*Linux*”​​ -and​​ $_.ToolsVersionStatus​​ -eq​​ "guestToolsNotInstalled"}​​ |​​ select​​ Name,GuestFullName,ToolsVersionStatus,ToolsVersion​​ |​​ FT​​ -a

 

VMs on Host with More than 2vCPU & 8GB Ram 

 

get-vm | Where-Object {$_.NumCpu -gt "2" -and $_.MemoryGB -gt "8"} | select N ame, NumCpu, MemoryGB, VMHost | Sort-Object NumCpu | ft -AutoSize

 

Network Adapter and VMs Connected to it

 

Get-Cluster "UK-​​ IHateSpurs-01" | Get-VM | Get-NetworkAdapter | Where {$_.NetworkName -match "UAT_DMZ" } | Select Parent, Name, Type, NetworkName, MacAddress | ft​​ –a

 

Get-VM or VMhost LOGS

 

(Get-Log -VMHost (Get-VMHost​​ ​​ IHateSpurs-01*) vmkernel).Entries | Where {$_ -like “*WARNING*“}

 

(Get-Log -VMHost (Get-VMHost​​ IHateSpurs-01*) hostd).Entries | Where {$_ -like “*WARNING*“}

 

(Get-Log -VMHost (Get-VMHost​​ IHateSpurs-01*) vpxa).Entries | Where {$_ -like “*WARNING*“}

 

HOSTD The vmware-hostd management service is the main communication channel between ESX/ESXi hosts and VMkernel

In ESX you have only hostd and (if you have vCenter) vpxa.

These are daemon (services) for remote management:

  • hostd is used to remote management using VIC

  • vpxa is used by vCenter (the vpxd part of vCenter) to remote manament

 

VPXA It acts as an intermediary between VC and hostd. The vCenter Server Agent,

 

VMs with Snaphot

 

Get-VM | Get-Snapshot | Select VM,Name,Description,@{Label="Size";Expression={"{0:N2} GB" -f ($_.SizeGB)}},Created | FT -a  

Snapshot Report to CSV

 

$VIServer="ron-vc01.​​ IHateSpurs.local"

If​​ (-not​​ (Get-PSSnapin​​ VMware.VimAutomation.Core))

{ ​​ Try​​ {​​ Add-PSSnapin​​ VMware.VimAutomation.Core​​ -ErrorAction​​ Stop​​ }

  ​​ Catch​​ {​​ Write-Host​​ "Unable to load PowerCLI, is it installed?"​​ -ForegroundColor​​ Red;​​ Break​​ }

}

Connect-VIServer​​ $VIServer​​ -Credential​​ (Get-Credential)​​ |​​ Out-Null

Get-VM​​ |​​ Get-Snapshot​​ |​​ Select​​ VM,Name,Description,@{Label="Size";Expression={"{0:N2} GB"​​ -f​​ ($_.SizeGB)}},Created​​ |​​ Export-Csv​​ C:\scripts\csv\snapshotreport.csv

 

## VM disk space usage
[math]::Round(((get-vm | Where-object{$_.PowerState -eq "PoweredOn" }).UsedSpaceGB | measure-Object -Sum).Sum)

## Check VM and VMtools level  
get-vm | where-object {$_.GuestFullName -like “*Linux*”} | select Name,GuestFullName,ToolsVersionStatus,ToolsVersion | FT -a

## Check VM and VMtools level and include the Ones that require tools only

get-vm | where-object {$_.GuestFullName -like “*Linux*” -and $_.ToolsVersionStatus -eq "guestToolsNotInstalled"} | select Name,GuestFullName,ToolsVersionStatus,ToolsVersion | FT -a

## VMs on Host with More than 2vCPU & 8GB Ram 

get-vm | Where-Object {$_.NumCpu -gt "2" -and $_.MemoryGB -gt "8"} | select N ame, NumCpu, MemoryGB, VMHost | Sort-Object NumCpu | ft -AutoSize

## Network Adapter and VMs Connected to it

Get-Cluster "UK- IHateSpurs-01" | Get-VM | Get-NetworkAdapter | Where {$_.NetworkName -match "UAT_DMZ" } | Select Parent, Name, Type, NetworkName, MacAddress | ft –a
 
## Get-VM or VMhost LOGS

(Get-Log -VMHost (Get-VMHost  IHateSpurs-01*) vmkernel).Entries | Where {$_ -like “*WARNING*“}

(Get-Log -VMHost (Get-VMHost IHateSpurs-01*) hostd).Entries | Where {$_ -like “*WARNING*“}

(Get-Log -VMHost (Get-VMHost IHateSpurs-01*) vpxa).Entries | Where {$_ -like “*WARNING*“}

HOSTD The vmware-hostd management service is the main communication channel between ESX/ESXi hosts and VMkernel
In ESX you have only hostd and (if you have vCenter) vpxa.
These are daemon (services) for remote management:
•	hostd is used to remote management using VIC
•	vpxa is used by vCenter (the vpxd part of vCenter) to remote manament

VPXA It acts as an intermediary between VC and hostd. The vCenter Server Agent,

## VMs with Snaphot

Get-VM | Get-Snapshot | Select VM,Name,Description,@{Label="Size";Expression={"{0:N2} GB" -f ($_.SizeGB)}},Created | FT -a  
Snapshot Report to CSV

$VIServer="ron-vc01. IHateSpurs.local"
If (-not (Get-PSSnapin VMware.VimAutomation.Core))
{  Try { Add-PSSnapin VMware.VimAutomation.Core -ErrorAction Stop }
   Catch { Write-Host "Unable to load PowerCLI, is it installed?" -ForegroundColor Red; Break }
}
Connect-VIServer $VIServer -Credential (Get-Credential) | Out-Null
Get-VM | Get-Snapshot | Select VM,Name,Description,@{Label="Size";Expression={"{0:N2} GB" -f ($_.SizeGB)}},Created | Export-Csv C:\scripts\csv\snapshotreport.csv


Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

When autocomplete results are available use up and down arrows to review and enter to go to the desired page. Touch device users, explore by touch or with swipe gestures.

Recent Posts

  • vROps: Management Pack Troubleshooting
  • Windows AD {Active Directory} (PowerShell) samples
  • Migrate VMs Between vCentres Using Powershell or PowerCLI
  • Set VM Tools to Update Automatically on VM Reboot using powershell
  • Windows Administrator Must Have Powershell Commands

Recent Comments

  • JB on Script: How to get VM with Tag Assignment and export results to csv using PowerCLI or Powershell
  • DL on How to change VCSA root password and bypass BAD PASSWORD: it is based on a dictionary word for vCenter VCSA root account warning
  • 360coolp on How to change VCSA root password and bypass BAD PASSWORD: it is based on a dictionary word for vCenter VCSA root account warning
  • Yogesh on ESXi 8.x, 7.x, 6.x Service sfcbd-watchdog Not Running / Fails to Start – VirtuallyThatGuy
  • VirtuallyThatGuy on ESXi 8.x, 7.x, 6.x Service sfcbd-watchdog Not Running / Fails to Start – VirtuallyThatGuy

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017

Categories

  • Automation
  • PowerCLI
  • VMware
  • Windows
© 2025 VirtuallyThatGuy | Powered by Superbs Personal Blog theme