<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Create SnapShot with error reporting (Try/Catch) in vSphere Update Manager PowerCLI Discussions</title>
    <link>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Create-SnapShot-with-error-reporting-Try-Catch/m-p/2205715#M539</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok a little more info, it works if i close and reopen the powershell window.&amp;nbsp; Is it possible its storing the System.Exception ?? Is there a way to clear it after each run?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Sep 2014 17:18:48 GMT</pubDate>
    <dc:creator>Korfu</dc:creator>
    <dc:date>2014-09-17T17:18:48Z</dc:date>
    <item>
      <title>Create SnapShot with error reporting (Try/Catch)</title>
      <link>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Create-SnapShot-with-error-reporting-Try-Catch/m-p/2205712#M536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok so my goal is to create a script that will automate creating a snapshot of a server but will catch errors and send an email based off the error.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From what I can tell Try/Catch blocks will be the best way to accomplish this.&amp;nbsp; This is what I have so far but I cant get it to catch the error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the snippet of the code&lt;/P&gt;&lt;P&gt;try&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;Get-VM $serverVMName | new-snapshot -Name "dppfr-$serverVMName-$TimeStr" -Description "Automated backup"&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;catch [system.exception]&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;sendError&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2014 16:59:38 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Create-SnapShot-with-error-reporting-Try-Catch/m-p/2205712#M536</guid>
      <dc:creator>Korfu</dc:creator>
      <dc:date>2014-09-17T16:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Create SnapShot with error reporting (Try/Catch)</title>
      <link>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Create-SnapShot-with-error-reporting-Try-Catch/m-p/2205713#M537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should add the parameter '-ErrorAction stop' on the &lt;A href="https://www.vmware.com/support/developer/PowerCLI/PowerCLI58R1/html/New-Snapshot.html"&gt;New-Snapshot&lt;/A&gt; cmdlet.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2014 17:12:03 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Create-SnapShot-with-error-reporting-Try-Catch/m-p/2205713#M537</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2014-09-17T17:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create SnapShot with error reporting (Try/Catch)</title>
      <link>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Create-SnapShot-with-error-reporting-Try-Catch/m-p/2205714#M538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If i put the ErrorAction stop it catches the error but then also executes the catch even on successes.&amp;nbsp; I have noticed that it executes the catch before the snapshot can finish, it has barely started by the time it executes the catch action. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2014 17:15:51 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Create-SnapShot-with-error-reporting-Try-Catch/m-p/2205714#M538</guid>
      <dc:creator>Korfu</dc:creator>
      <dc:date>2014-09-17T17:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: Create SnapShot with error reporting (Try/Catch)</title>
      <link>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Create-SnapShot-with-error-reporting-Try-Catch/m-p/2205715#M539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok a little more info, it works if i close and reopen the powershell window.&amp;nbsp; Is it possible its storing the System.Exception ?? Is there a way to clear it after each run?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2014 17:18:48 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Create-SnapShot-with-error-reporting-Try-Catch/m-p/2205715#M539</guid>
      <dc:creator>Korfu</dc:creator>
      <dc:date>2014-09-17T17:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create SnapShot with error reporting (Try/Catch)</title>
      <link>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Create-SnapShot-with-error-reporting-Try-Catch/m-p/2205716#M540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Also when you leave out the specific exception type on the Catch block ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="text-align: Left; font-family: Segoe UI; font-style: normal; font-weight: normal; font-size: 12; color: #000000;"&gt;&lt;P style="font-family: Lucida Console; margin: 0 0 0 0; background-color: #ffffff;"&gt;&lt;SPAN style="font-size: 16;"&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #00008b;"&gt;&lt;SPAN&gt;Try&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: Lucida Console; margin: 0 0 0 0; background-color: #ffffff;"&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;SPAN&gt;Get-VM&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #ff4500;"&gt;&lt;SPAN&gt;$serverVMName&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #a9a9a9;"&gt;&lt;SPAN&gt;|&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: Lucida Console; margin: 0 0 0 0; background-color: #ffffff;"&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;SPAN&gt;New-Snapshot&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;&lt;SPAN&gt;-Name&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #8b0000;"&gt;&lt;SPAN&gt;"dppfr-&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #ff4500;"&gt;&lt;SPAN&gt;$serverVMName&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #8b0000;"&gt;&lt;SPAN&gt;-&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #ff4500;"&gt;&lt;SPAN&gt;$TimeStr&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #8b0000;"&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;&lt;SPAN&gt;-Description&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #8b0000;"&gt;&lt;SPAN&gt;"Automated backup"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;&lt;SPAN&gt;-ErrorAction&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #8a2be2;"&gt;&lt;SPAN&gt;stop&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: Lucida Console; margin: 0 0 0 0; background-color: #ffffff;"&gt;&lt;SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: Lucida Console; margin: 0 0 0 0; background-color: #ffffff;"&gt;&lt;SPAN style="color: #00008b;"&gt;&lt;SPAN&gt;Catch&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: Lucida Console; margin: 0 0 0 0; background-color: #ffffff;"&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;SPAN&gt;sendError&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: Lucida Console; margin: 0 0 0 0; background-color: #ffffff;"&gt;&lt;SPAN&gt;&lt;SPAN&gt;} &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2014 17:19:26 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Create-SnapShot-with-error-reporting-Try-Catch/m-p/2205716#M540</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2014-09-17T17:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create SnapShot with error reporting (Try/Catch)</title>
      <link>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Create-SnapShot-with-error-reporting-Try-Catch/m-p/2205717#M541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #666666; font-family: proxima-nova, Arial, sans-serif; font-size: 14px;"&gt;Ok a little more info, it works if i close and reopen the powershell window.&amp;nbsp; Is it possible its storing the System.Exception ?? Is there a way to clear it after each run?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2014 17:25:54 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Create-SnapShot-with-error-reporting-Try-Catch/m-p/2205717#M541</guid>
      <dc:creator>Korfu</dc:creator>
      <dc:date>2014-09-17T17:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Create SnapShot with error reporting (Try/Catch)</title>
      <link>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Create-SnapShot-with-error-reporting-Try-Catch/m-p/2205718#M542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There should be no need to do that.&lt;/P&gt;&lt;P&gt;From where do you run the script ? From the PowerCLI prompt ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2014 18:19:34 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Create-SnapShot-with-error-reporting-Try-Catch/m-p/2205718#M542</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2014-09-17T18:19:34Z</dc:date>
    </item>
  </channel>
</rss>

