{"id":1761,"date":"2020-11-28T21:24:29","date_gmt":"2020-11-28T20:24:29","guid":{"rendered":"https:\/\/blog.mhasin.eu\/?p=1761"},"modified":"2020-11-28T21:24:35","modified_gmt":"2020-11-28T20:24:35","slug":"vmware-cli-get-all-snapshot-script","status":"publish","type":"post","link":"https:\/\/blog.mhasin.eu\/?p=1761","title":{"rendered":"VMWARE CLI get all snapshot script"},"content":{"rendered":"\n<p>POVERCLI script<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$myVMs = Get-VM\n$VMsWithSnaps = @()\nforeach ($vm in $myVMs) {\n    $view2 = $vm | Get-Annotation  -Name email\n    $snap = $vm | get-snapshot\n    $vmView = $vm | Get-View\n    if ($vmView.snapshot -ne $null) {\n        Write-Host \"VM $vm has a snapshot\"\n        $SnapshotEvents = Get-VIEvent -Entity $vm -type info -MaxSamples 1000 | Where {\n            $_.FullFormattedMessage.contains(\"Create virtual machine snapshot\")}\n        try {\n        $user = $SnapshotEvents&#91;0].UserName\n        $time = $SnapshotEvents&#91;0].CreatedTime\n        $view3 = $view2.Value\n        $snap2 = $snap.Description\n        $snapname = $snap.Name\n        } catch &#91;System.Exception] {\n            $user = $SnapshotEvents.UserName\n            $time = $SnapshotEvents.CreatedTime\n        }\n        $VMInfo = .. | Select \"VM\",\"CreationDate\",\"User\",\"Snapname\",\"Description\",\"Email\"\n        $VMInfo.\"VM\" = $vm.Name\n        $VMInfo.\"CreationDate\" = $time\n        $VMInfo.\"User\" = $user\n        $VMInfo.\"Email\" = $view3\n        $VMInfo.\"Description\" = $snap2\n        $VMInfo.\"Snapname\" = $snapname\n        $VMsWithSnaps += $VMInfo\n    }\n}\n$VMsWithSnaps | Sort CreationDate  | Export-Csv -Path C:\\Users\\$env:username\\Desktop\\snapshots.csv\n<\/code><\/pre>\n<div class=\"pdf24Plugin-cp\"> \t<form name=\"pdf24Form0\" method=\"post\" action=\"https:\/\/doc2pdf.pdf24.org\/wordpress.php\" target=\"pdf24PopWin\" onsubmit=\"var pdf24Win = window.open('about:blank', 'pdf24PopWin', 'resizable=yes,scrollbars=yes,width=600,height=250,left='+(screen.width\/2-300)+',top='+(screen.height\/3-125)+''); pdf24Win.focus(); if(typeof pdf24OnCreatePDF === 'function'){void(pdf24OnCreatePDF(this,pdf24Win));}\"> \t\t<input type=\"hidden\" name=\"blogCharset\" value=\"Cw1x07UAAA==\" \/><input type=\"hidden\" name=\"blogPosts\" value=\"MwQA\" \/><input type=\"hidden\" name=\"blogUrl\" value=\"yygpKSi20tdPyslP18vNSCzOzNNLLQUA\" \/><input type=\"hidden\" name=\"blogName\" value=\"c\/LxdwcA\" \/><input type=\"hidden\" name=\"blogValueEncoding\" value=\"gzdeflate base64\" \/><input type=\"hidden\" name=\"postId_0\" value=\"MzQ3MwQA\" \/><input type=\"hidden\" name=\"postTitle_0\" value=\"C\/MNdwxyVXD28VRITy1RSMzJUSjOSywozsgvUShOLsosKAEA\" \/><input type=\"hidden\" name=\"postLink_0\" value=\"yygpKSi20tdPyslP18vNSCzOzNNLLdW3L7A1NDczBAA=\" \/><input type=\"hidden\" name=\"postAuthor_0\" value=\"y00syfcwNAIA\" \/><input type=\"hidden\" name=\"postDateTime_0\" value=\"MzIwMtA1NNQ1slAwMrQyNLQysgQA\" \/><input type=\"hidden\" name=\"postContent_0\" value=\"fVRdb9pAEHz3r1i5VgVq7ZDkqSmgVoS0SKGN6hZeiKqrWcIp9tnyLQ6o5b9374yN+Wj9Yt\/u3Nzs7PqcbtZ\/+DoZfhvcj0BHucyoe5H1HX66WY4QxULrnvuS+b\/iNHr2o3SObr9rXn0v2UzGGnrwCcmfjB2PV1NJy1CJzIQ\/tNrOIs1RREtoeUUCUkG5pw2\/HeDHKyS+XDHUZP9Yno9KpSRIpgrA\/yISBEyEjEu4ZuYa\/cRoE9DLlHZsyYT5DuhMwCblwmow66DaBb5C8NQqjitB5pnmktD\/nGoCdzK2XEuhQUC1za2hXrgLDQtUVFsxskvwh4okbSyDT5sM2YBFCv5YrEORZDFquOx0Oqx0ukT2ei\/Bcv8M7ljZXZonggjnY9RaPGEQpYqEVLrlDthaQihkTisRQ8I+Sy6oltne1oSUbxr03kpjbmw6lP\/61bvL953H4AdnjfN7PEnuwz\/xpY75d9ncYjp7bVthWhxMRLxqZI1G23fzEdxiOXnc9EOIEuW5FnUgaQuRIJ4rqyHcaMIkGK4jtCSPx1aer\/e00P8Ue7bKvcE8+yPT3B4EATc0xBgjOz\/u27JPLOuW9\/PSnMqvcFcffzbq59XQzLt7zBwYrnK0D52o8wfHGCTJczB7vEkbU07T5elV465PAU2xVW+uTmF1eRVGHYluXBVvetU+p3R1e3SXsKFpTtCsEDg4XGcc9ge6AP9B0BIGNzNTnp55qIobU6A5dcaSnynNZtWfoYNIF073wt5ifN3l2Hf+Ag==\" \/> \t\t<a href=\"https:\/\/www.pdf24.org\" target=\"_blank\" title=\"www.pdf24.org\" rel=\"nofollow\"><img src=\"https:\/\/blog.mhasin.eu\/wp-content\/plugins\/pdf24-post-to-pdf\/img\/pdf_32x32.png\" alt=\"\" border=\"0\" height=\"32\" \/><\/a> \t\t<span class=\"pdf24Plugin-cp-space\">&nbsp;&nbsp;<\/span> \t\t<span class=\"pdf24Plugin-cp-text\">Send article as PDF<\/span> \t\t<span class=\"pdf24Plugin-cp-space\">&nbsp;&nbsp;<\/span> \t\t<input class=\"pdf24Plugin-cp-input\" style=\"margin: 0px;\" type=\"text\" name=\"sendEmailTo\" placeholder=\"Enter email address\" \/> \t\t<input class=\"pdf24Plugin-cp-submit\" style=\"margin: 0px;\" type=\"submit\" value=\"Send\" \/> \t<\/form> <\/div>","protected":false},"excerpt":{"rendered":"POVERCLI script &nbsp;&nbsp; Send article as PDF &nbsp;&nbsp;\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"arc_restricted_post":false,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-1761","post","type-post","status-publish","format-standard","hentry","category-vmware"],"_links":{"self":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts\/1761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1761"}],"version-history":[{"count":1,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts\/1761\/revisions"}],"predecessor-version":[{"id":1762,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts\/1761\/revisions\/1762"}],"wp:attachment":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}