One of my scripts stopped working and it turned out the FullFormattedMessage has changed for the snapshot events and I was wondering what could have caused this behavior?
My requirement was to produce a report that includes the user who created the snapshot and so I did, and it worked fine for a few months. To my knowledge we have not done any vCenter upgrades and/or DB work.
I was wondering why the report started coming back blank and it turned out FullFormattedMessage no longer contains the string I am looking for. I am using something like this:
PowerCLI C:\> $snapshots = Get-Snapshot -VM pnlvsprXXXX
PowerCLI C:\> Get-VIEvent -Start ($snapshots.Created).addminutes(-5) -Finish ($snapshots.Created).addminutes(5) -Entity $Snapshots.vm.name -Types info -maxsamples 20 | Where-Object {($_.FullFormattedMessage -like "*Create virtual machine snapshot*")}
PowerCLI C:\>
the above doesn't match anything
If I look at the event itself it now contains something else as FullFormattedMessage: "Task: VirtualMachine.createSnapshot". Also there is a slight discrepancy between the time stamp of the Get-VIEvent 07:59:47 and the time stamp 07:59:48 reported by the next snippet below:
Info : VMware.Vim.TaskInfo
Key : 14054888
ChainId : 14054888
CreatedTime : 16/05/2017 07:59:47
UserName : XXXX\admin_XXXXX
Datacenter : VMware.Vim.DatacenterEventArgument
ComputeResource : VMware.Vim.ComputeResourceEventArgument
Host : VMware.Vim.HostEventArgument
Vm : VMware.Vim.VmEventArgument
Ds :
Net :
Dvs :
FullFormattedMessage : Task: VirtualMachine.createSnapshot
ChangeTag :
PowerCLI C:\> Get-Snapshot -VM pnlvsprXXXX | Select VM,Name,@{Label="Size";Expression={"{0:N2} GB" -f ($_.SizeGB)}},Created | Sort-Object Created -descending
VM Name Size Created
pnlvsprXXXX CHGXXXXXX-JD 10.61 GB 16/05/2017 07:59:48
To go around this I have amended the clause like this using "-or" but am still perplexed as to why the sudden change
Where-Object {($_.FullFormattedMessage -like "*Create virtual machine snapshot*") -or ($_.FullFormattedMessage -like "*VirtualMachine.createSnapshot*")}
PowerCLI C:\> Get-VIEvent -Start ($snapshots.Created).addminutes(-5) -Finish ($snapshots.Created).addminutes(5) -Entity $Snapshots.vm.name -Types info -maxsamples 20 | Where-Object {($_.FullFormattedMessage -like "*Create virtual machine snapshot*") -or ($_.FullFormattedMessage -like "*VirtualMachine.createSnapshot*")}
Info : VMware.Vim.TaskInfo
Key : 14054888
ChainId : 14054888
CreatedTime : 16/05/2017 07:59:47
UserName : XXXX\admin_XXXXX
Datacenter : VMware.Vim.DatacenterEventArgument
ComputeResource : VMware.Vim.ComputeResourceEventArgument
Host : VMware.Vim.HostEventArgument
Vm : VMware.Vim.VmEventArgument
Ds :
Net :
Dvs :
FullFormattedMessage : Task: VirtualMachine.createSnapshot
ChangeTag :
Thanks in advance for sharing you knowledge and experiences around this!
George