Who created the snapshot
No idea how I can relatemy Get-Snapshot information information Get-VIEvent to determine who created a snapshot?
Thank you
Alan
Small question, but a long answer. In the end, I arrived.
There were a few quirks in writing this script.
(1) the timestamp of creation in the event object is not always exactly the same as the timestamp in the property instant VirtualMachine.
The solution is to use the entity property of the task to get the timestamp of the snapshot.
(2) the Get-ViEvent cmdlet returns a VimApi.ManagedObjectReference instead of a VMware.Vim.ManagedObjectReference.
So this isn't a big problem because I can easily convert a MoRef (unfortunately not by casting).
(3) the speed of the Get-ViEvent cmdlet is not ideal compered to the task of the collector of the API
(2) and 3) I decided to go for the collector's working methods.
The flow of the script is very simple.
First create a hash of all the tasks table that created snapshots on specific comments.
The key in the hash table is the name of the guest concatenated with the snapshot creation timestamp.
Then the script use the cmdlet Get-Snapshot to retrieve snapshots for the guests.
This output is built a key and then the key is used to search for the user in the hash table.
The user property is added to the SnapshotImpl object.
function Get-SnapshotTree{ param($tree, $target) $found = $null foreach($elem in $tree){ if($elem.Snapshot.Value -eq $target.Value){ $found = $elem continue } } if($found -eq $null -and $elem.ChildSnapshotList -ne $null){ $found = Get-SnapshotTree $elem.ChildSnapshotList $target } return $found } $daysBack = 3 # How many days back from now $guestName =# The name of the guest $tasknumber = 999 # Windowsize of the Task collector #$serviceInstance = get-view ServiceInstance $taskMgr = Get-View TaskManager # Create hash table. Each entry is a create snapshot task $report = @{} $filter = New-Object VMware.Vim.TaskFilterSpec $filter.Time = New-Object VMware.Vim.TaskFilterSpecByTime $filter.Time.beginTime = (Get-Date).AddDays(-$daysBack) $filter.Time.timeType = "startedTime" $collectionImpl = Get-View ($taskMgr.CreateCollectorForTasks($filter)) $dummy = $collectionImpl.RewindCollector $collection = $collectionImpl.ReadNextTasks($tasknumber) while($collection -ne $null){ $collection | where {$_.DescriptionId -eq "VirtualMachine.createSnapshot" -and $_.State -eq "success" -and $_.EntityName -eq $guestName} | %{ $row = New-Object PsObject $row | Add-Member -MemberType NoteProperty -Name User -Value $_.Reason.UserName $vm = Get-View $_.Entity $snapshot = Get-SnapshotTree $vm.Snapshot.RootSnapshotList $_.Result $key = $_.EntityName + "&" + ($snapshot.CreateTime.ToString()) $report[$key] = $row } $collection = $collectionImpl.ReadNextTasks($tasknumber) } $collectionImpl.DestroyCollector() # Get the guest's snapshots and add the user $snapshotsExtra = Get-VM $guestName | Get-Snapshot | % { $key = $_.vm.Name + "&" + ($_.Created.ToString()) if($report.ContainsKey($key)){ $_ | Add-Member -MemberType NoteProperty -Name User -Value $report[$key].User } $_ } $snapshotsExtra | Export-Csv "C:\SnapshotsExtra.csv" -NoTypeInformation -UseCulture
Note1: the parameter - UseCulture to the Export-Csv cmdlet is PS v2 CTP3
Note 2: it should not be too difficult to convert the script to handle all the guests instead of one. The name of the guest is already in the key in the hash table.
Tags: VMware
Similar Questions
-
Script to determine who created a snapshot
Hi all
I have the following script, I need help to add code to determine who created the snapshot.
Get - VM | Get-Snapshot | Where {$_.} Created - lt (Get-Date). AddDays(-2)} | Select name, creation, VM, SizeMB
Try this,
Get - vm | Get-vievent | WHERE-object {$_ .fullformattedmessage - like ' * snapshot * "} | Select-object @{N = "VM"; {E = {$_.vm.name}}, username, FullFormattedMessage, Createduserid
It will signal you the snapshot so delete event.
-
Inability to create the snapshot (General error) - need help
Hello
Since 3 days, snapshot is no longer working with one of my VM (is a production machine).
Vsphere Client 5.5.0 I got a General in vSphere Client error when I do a snapshot. In management of snapshot section, I see no snapshot
but when I go into the directory of the virtual machine by ssh is to see that below (there are a few photos...)
I tried to create the snapshot with and without the data from the memory, but it always the same effect. (Snapshot is taken with the virtual machine is turned on).
- What am I trying to consolidate the disk? Is it safe?
- Can someone help me?
Thanks in advance,
Michael
VMware - 4.log
VMware - 5.log
VMware - 6.log
VMware - 7.log
VMware - 8.log
VMware - 9.log
VMware.log
VMX-prod03-64-Ubuntu-2098329481-1.vswp
prod03-64-ubuntu-000001 - ctk.vmdk
prod03-64-ubuntu-000001 - delta.vmdk
prod03-64-ubuntu - 000001.vmdk
prod03-64-ubuntu-000002 - ctk.vmdk
prod03-64-ubuntu-000002 - delta.vmdk
prod03-64-ubuntu - 000002.vmdk
prod03-64-ubuntu-000003 - ctk.vmdk
prod03-64-ubuntu-000003 - delta.vmdk
prod03-64-ubuntu - 000003.vmdk
prod03-64-ubuntu-000004 - ctk.vmdk
prod03-64-ubuntu-000004 - delta.vmdk
prod03-64-ubuntu - 000004.vmdk
prod03-64-ubuntu-000005 - ctk.vmdk
prod03-64-ubuntu-000005 - delta.vmdk
prod03-64-ubuntu - 000005.vmdk
prod03-64-ubuntu-000006 - ctk.vmdk
prod03-64-ubuntu-000006 - delta.vmdk
prod03-64-ubuntu - 000006.vmdk
prod03-64-ubuntu - 7d11f789.vswp
prod03-64-ubuntu - Snapshot137.vmsn
prod03-64-ubuntu - Snapshot138.vmsn
prod03-64-ubuntu - Snapshot139.vmsn
prod03-64-ubuntu - Snapshot140.vmsn
prod03-64-ubuntu - Snapshot141.vmsn
prod03-64-ubuntu - Snapshot142.vmsn
prod03-64-ubuntu - ctk.vmdk
prod03-64-ubuntu - flat hard
prod03-64 - ubuntu.nvram
prod03-64 - ubuntu.vmdk
prod03-64 - ubuntu.vmsd
prod03-64 - ubuntu.vmx
prod03-64 - ubuntu.vmx.lck
prod03-64 - ubuntu.vmxf
I found the problem
Some VM had a disc mounted in vSphere. It worked until last week, don't know why this problem only appears now.
After you have disconnected the CD, 'manage the snapshot' list still empty, I clicked on consolidate first, after that, back to 'manage the snapshot' and my snapshots
appeared. And last step, I deleted this snapshot for merge all...
Maybe this will help someone else...
-
We test VDR on our ESXi 4.1.0 cluster 381591 and we have a few backups to a test Windows 2003 server and a Linux server and they backed up fine. We have a backup of a Windows 7 computer virtual test and we had a bunch of these errors...
Failed to create the snapshot for systemname, error-3960 (can not suspend virtual machine)
Which is strange because I can go in vSphere client and manually create a snapshot and remove without problem. Any ideas on why this is happening?
Thank you
You can try to set the 'disk. EnableUUID' to 'false '.
Look here:
Paul
-
I vSphere 4.0.0 208111 using VDR 1.1.0.707 appliance for backup of a Windows Server 2003 SP2 with VMware tools installed (including the VSS component).
I am unable to back up a VM, but can save all other virtual machines.
Have tried to re - install VMware tools, ensuring Windows VSS patches are up to date.
I can do a ntbackup to system within the virtual machine with success status.
Impossible to find someone else suffer the same error with-3491, create the snapshot has failed.
Any ideas?
Paul
To simulate a VDR initiated snapshot, try a manual snapshot of the virtual machine and see if it passes or fails. If it fails, then that explains the error 3941. Be sure to uncheck the memory status and check the comments of quiesce file system option during an attempt of the manual snapshot because it will mimic the snapshot operation that initiates the VDR.
-
How to find the owner of the user or who created the user?
Hi all
I want to know owner of user or users who created?
example:
system created the test user.
test has created the user xyz.
So I want to know who created xyz?
Thanks in advance,
Sandeep.You can not find who created the user unless you enable the audit of the database or write a trigger (CREATE ddl event-based) that will track the session information of the user who executes a command from the user to CREATE.
-
Create the snapshot on VCenter VM during the process of upgrading to VCenter 5.1?
People,
My VCenter server is a virtual machine running on the host ESXi number 01 (I've nailed specifically using the DRS rule), so it is desirable to take snapshots for VCenter Server VM during the upgrade process?
What happened when the upgrade process has failed? can I safely restored the snapshot?
When the snapshot is created before the upgrade, it means that the snapshot will be the safe state of the VM, vCenter and SQL in your case. But if you can make a backup of database to an external location.
-
Create the snapshot and paste in different PDF in Adobe Reader DC is broken
Creating a snapshot and pasting to a different PDF in Adobe Reader DC are broken
When I paste the snapshot to the 2013 Word and copy it again I can stick it in the PDF without problem.
Hello
Can you please let me know the complete workflow, exactly what you're trying to achieve?
Copy paste & images is part of edition & you can't edit PDF using the Adobe Acrobat Reader DC.
For this will need you Adobe Acrobat application (Adobe Acrobat free trial downloadversion |) Acrobat Pro DC).
Kind regards
Nicos
-
Two vCenter servers - updated to 5.0 and the other left to 4.1 for now. All ESXi hosts are always 4.1u1. Updated vDR devices since the notes say 2.0 is compatible with 4.0u3, 4.1u1 and 5.0, but now none of my backups work. No matter what vCenter the plugin works through, each virtual machine backup process immediately fails with the error "failed to create the capture instant for VMname, error-3961 (cannot disable Storage VMotion). I can still take snapshots manually via vSphere Client, so I don't know why vDR fail to take a. Ideas?
Add a few lines to datarecovery.ini on VDR:
[Options]
EnableSVMotionCompatibility = 0
and reboot device here. Page 44 of VDR Admin Guide.
-
How to create the snapshot to the remote data store?
Hi all.
I have esxi 4.1 now if I run the snapshot in the snapshot file created on the host server, but I want to create the file snapshot directly to remote NAS. Can I do this?
Thanks in advance.
best account.
Dan.
check this, you can set a different location of snapshot: http://blog.vmpros.nl/2009/05/14/vmware-creating-snapshots-in-a-different-location-than-default-virtual-machine-directory-1002929/
-
Create the snapshot in another data store
Hi all
On ESXi 4, is it possible to create snapshot in another data store? The reason is that the current data store is almost full. Thank you.
Hello
As far as I know, the snapshots are always in the same place as the files of the virtual machine. Then, it is not possible to snapshots in the other data that the VM store.
Best wishes / Saludos.
Pablo
Please consider providing any useful answer. Thank you!! - Por favor considered premiar las useful responses. ¡¡MUCHAS gracias!
-
PowerCLI script delete/create the snapshot in ESXi5.5
Hello
Last week, I upgraded one of my host of esxi5.1 to 5.5
everythink works exepted one of my script powerCLI.
On my host 5.5, I can't throw a snapshots of delete/create:
Remove-Snapshot: 14/11/2013-13:45:37 Remove-Snapshot Current permit or version ESXi prohibited the execution of the requested operation.
At line: 1 char: 92
+ Get - VM | Get-Snapshot | Where {$_.} Created - lt ((Get-Date).) AddHours(-46))} | R
eMove-Snapshot < < < <-confirm: $false
+ CategoryInfo : NotSpecified: (:)) [delete-screenshot], RestrictedV) ersion
+ FullyQualifiedErrorId: Client20_VMServiceImpl_RemoveSnapshot_ViError, VM ware.VimAutomation.ViCore.Cmdlets.Commands.RemoveSnapshot
A feature has been remove en 5.5?
Thank you
I guess that's not possible. This has already been discussed in communities. Please take a look at this thread. https://communities.VMware.com/message/2211533
~ dGeorgey
-
Who created the interface user of Windows XP?
I want to tip my hat to this designer. Who did he was very intelligent. One thing had to be added. An easy tablecloth on your black eyes theme.
Would never happen, but there are 3rd party apps that have dark (and black) skin packs.
-
standby of the comments file system create two snapshot files
Why would or should suspend the comments file system create two snapshot files.
In our environment, we have the following VMDK.
Syntest.VMDK
Syntest_1.VMDK
Syntest_2.VMDK
Syntest_3.VMDK
Syntest_4.VMDK
When I create a snapshot that suspends the comments file system it creates two syntest_1 - 000001.vmdk and syntest_1.000002.vmdk (as well as all of the files for snapshots). Here is a screenshot.
Why and is at - it something wrong? I can find a ton of articles on stereotypes, but nothing that speaks.
We are currently on ESXi 5.1.0,1157734.
Thank you
Mike
Out of curiosity. Are two snapshots created even when you create the snapshot manually?
With backup applications, this behavior is not uncommon. The first snapshot is created for the virtual machine write them changed data, while the current is/instant backup, and the second snapshot is created by the backup software to attach the virtual disk basic to the host/proxy backup as "independent - not persistent. Once the virtual disk is disconnected from the proxy the second snapshot will be discarded and then the first snapshot will be validated for the basic disk.
CBT information should not be reset somehow, but updated as changed during the backup data.
André
-
RestrictedVersionFault then he tried to create a snapshot of the CLI
I try to create a snapshot of a computer virtual hosted by a server ESXi 4.1 using the CLI from a Windows PC.
The command I issue sounds like
VSphere C:\Programmi\VMware\VMware CLI\bin > vmware - cmd.pl - H "192.168.1.1" - U root "/ vmfs/volumes/datastore1/New Machine.vmx Virtual Machine virtual/New" create snapshot "snapshot1" "Snapshot created by Marius da" 0 0
The error I get is:
Fault:
SOAP fault:
-----------
Error string: error. RestrictedVersion.summary
Lack of details: RestrictedVersionFaultRead the other posts in this forum, I suspect that the problem is related to the free license that I use: is this correct?
Is there any other possible reason, perhaps related to the syntax I used?
If so, is there another way to create a snapshot from a command line?
Concerning
Marius
Hi Marius1,
ESXi free edition is limited to read only RCLI. That sounds like the problem.
If you have access to the console, you can run the command directly on the console.
Give it a whirl on the free edition to see if it works.
1. you must first find the id of the virtual machine virtual computer by running "vim - cmd vmsvc/getallvms".
(Use the id of the virtual machine, you want instant and enter it in the command in step 2)2. create the snapshot by running "vim - cmd /vmsvc/snapshot.create
for example, vim - cmd /vmsvc/snapshot.create 16 VMSnapshot SnapShotBeforeUpgrading true.Thank you
Nick.
Maybe you are looking for
-
What do the lights on the front of my NB-205?
I know what means the plug icon (plugged into the wall). I know that the symbol of wifi: I am connected to wifi. I know what means the battery light, (although I don't know when it lights up). The rest of the lights are an enigma for me, however. Any
-
Lenovo Z570 - how to disable automatic brightness adjustment?
It's driving me absolutely crazy! This only happens when I run the laptop out of the battery. And when I go to a website with a dark background, the display automatically dims down. Then when I'm on a brighter site, then screen lights back up again.
-
Windows Update restart Notification keeps coming
I have a user who keeps having notified it needs to restart his PC because updates have been applied and they need of a reboot. The only thing that is good when the window comes up to him "restart now" is grayed out and only "restart later" is click
-
Why doesn't Windows 7 with a default email client installed?
original title: no e-mail in Windows 7? What a rip. I just bought a HP mini PC with Windows 7. Could you think that Windows 7 does not come with email? (ie the mail client) What is the point of making an operating system that does not have e-mail? Wi
-
HelloI have a copy of the PS5 I bought and use it on a PC, I think now to put either a MacBook Pro or Surface Book Pro, can I transfer this to another of these?