Library / Virtualization

VIRT-005 · Script

Virtual Machine Inventory Report

Lists virtual machines with their power state, guest operating system, hardware version, lifecycle dates and configured resources.

Version 1.0.0Language PowerShellUpdated November 2026Report only, changes nothing

What it does

Read-only. Nothing is changed. Writes one CSV row per virtual machine to -ReportDir.

Columns include: host, power state, uptime, guest operating system, hardware or configuration version, generation (Hyper-V) or firmware (VMware), virtual CPUs, configured and assigned memory, disk count and total provisioned size, network adapter count, checkpoint or snapshot count, creation date, folder or path, and notes.

Hyper-V reads the guest operating system name from the data the guest shares with the host (Key-Value Pair Exchange), so it is only filled in for running VMs with that integration service enabled. VMware reads it from VMware Tools, or from the VM's configured guest type when Tools is not running.

-FlagOlderThanDays optionally flags VMs that are powered off and were created more than that many days ago, which often points to VMs that are no longer needed. Runs silently. No prompts.

Requirements

Windows PowerShell 5.1+. Hyper-V: the Hyper-V PowerShell module. VMware: VMware PowerCLI installed by you.

How to run it

  • Run from: an admin workstation or scheduled task with the Microsoft modules installed and app sign-in configured
  • This is an admin script for your Virtualization tenant, not a per-device endpoint script
  • User interaction: none with app-only sign-in
  • Schedule: run on demand, or weekly for reports

Settings

NameWhat it doesOptionsDefault
PlatformHyperV (default) or VMware.HyperV, VMwareHyperV
VMNameVirtual machine names, wildcards allowed, for example "LAB-*". Empty = all VMs.(none)
FlagOlderThanDaysFlag powered-off VMs created more than this many days ago, for example 180. 0 (default) = off.0
ComputerNameHyper-V only. Name of a remote Hyper-V host, for example HV01. Leave empty to use this computer. The account running the script needs Hyper-V administrator rights on that host.
ServerVMware only. vCenter Server or ESXi host name, for example vcenter.school.local.
CredentialPathVMware only. Path to a credential file created with Get-Credential | Export-Clixml, for example C:\ProgramData\Runbookia\Secure\vcenter.xml. Create the file as the same account (for example SYSTEM) on the same computer that runs this script; Windows encrypts it so no other account can read it. Not needed with UseExistingSession.
UseExistingSessionVMware only. Reuse a vCenter Server or ESXi connection that is already open in this PowerShell session (from Connect-VIServer) instead of CredentialPath.False
IgnoreCertificateErrorsVMware only. Accept an untrusted or self-signed server certificate for this run only. Off by default; the PowerCLI setting on disk is not changed.False
ReportDirFolder for CSV reports. Default C:\ProgramData\Runbookia\Reports.C:\ProgramData\Runbookia\Reports

Exit codes

  • 0 = Inventory written
  • 1 = A named VM was not found, or VMs were flagged by FlagOlderThanDays
  • 2 = Script error (missing module, connection failed)

Testing steps

  1. Run it on one test tenant or small OU and check the output and log.
  2. Check the exit code: 0 = OK, 1 = needs attention, 2 = error (see log), 9 = this copy is past its Valid until date.
  3. Roll out to a small group next, then everyone.

Rollback steps

Report only. Nothing is changed, so nothing needs to be rolled back.

Version and change log

VersionDateChanges
1.0.0November 2026First release.