PoshCode Archive  Artifact [42987b6935]

Artifact 42987b69358216f87f759854f23ccd4e9a6aebe9a15ee0311310f35e2027e2df:

  • File Get-VMCreationReport.ps1 — part of check-in [528208f2c9] at 2018-06-10 12:59:56 on branch trunk — Produces a report of the number of and names of VMs created broken down by month and year. (user: unknown size: 845)

# encoding: ascii
# api: powershell
# title: Get-VMCreationReport
# description: Produces a report of the number of and names of VMs created broken down by month and year.
# version: 0.1
# type: script
# license: CC0
# function: Get-VMCreationReport
# x-poshcode-id: 1679
# x-archived: 2010-03-06T09:58:11
#
#
# Report VMs created per month.
# Before you begin run Alan's "Who Created that VM?" script.
# http://www.virtu-al.net/2010/02/23/who-created-that-vm/
function Get-VMCreationReport {
	Get-VM | Group {
		if ($_.CustomFields["CreatedOn"] -as [DateTime] -ne $null) {
			"{0:Y}" -f [DateTime]$_.CustomFields["CreatedOn"]
		} else {
			"Unknown"
		}
	}
}

# To create a CSV of this stuff try:
# Get-VMCreationReport | select Count, Name, { $_.Group -as [String] } |
#	export-csv c:\report.csv -NoTypeInformation