File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ <# PSScriptInfo
2
+ .VERSION 1.0.0
3
+ .GUID 62fd99cb-5129-47b4-ae95-8bdf31d829dc
4
+ .AUTHOR William Lam
5
+ .COMPANYNAME VMware
6
+ .COPYRIGHT Copyright 2021, William Lam
7
+ .TAGS VMware VM Deleted
8
+ .LICENSEURI
9
+ .PROJECTURI https://github.com/lamw/vghetto-scripts/blob/master/powershell/VmDeleteHistory.ps1
10
+ .ICONURI https://blogs.vmware.com/virtualblocks/files/2018/10/PowerCLI.png
11
+ .EXTERNALMODULEDEPENDENCIES
12
+ .REQUIREDSCRIPTS
13
+ .EXTERNALSCRIPTDEPENDENCIES
14
+ .RELEASENOTES
15
+ 1.0.0 - Initial Release
16
+ .PRIVATEDATA
17
+ .DESCRIPTION This function retrieves information about deleted VMs
18
+ #>
19
+ Function Get-VMDeleteHistory {
20
+ <#
21
+ . NOTES
22
+ ===========================================================================
23
+ Created by: William Lam
24
+ Organization: VMware
25
+ Blog: www.virtuallyghetto.com
26
+ Twitter: @lamw
27
+ ===========================================================================
28
+ . PARAMETER MaxSamples
29
+ Specifies the maximum number of retrieved events (default 500)
30
+ . EXAMPLE
31
+ Get-VMDeleteHistory
32
+ . EXAMPLE
33
+ Get-VMDeleteHistory -MaxSamples 100
34
+ #>
35
+ param (
36
+ [Parameter (Mandatory = $false )]$MaxSamples = 500
37
+ )
38
+
39
+ $results = @ ()
40
+ $events = Get-VIEvent - MaxSamples $MaxSamples - Types Info | where {$_.GetType ().Name -eq " TaskEvent" -and $_.FullFormattedMessage -eq " Task: Delete virtual machine" }
41
+
42
+ foreach ($event in $events ) {
43
+ $tmp = [pscustomobject ] @ {
44
+ VM = $event.Vm.Name ;
45
+ User = $event.UserName ;
46
+ Date = $event.CreatedTime ;
47
+ }
48
+ $results += $tmp
49
+ }
50
+ $results
51
+ }
You can’t perform that action at this time.
0 commit comments