<?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: Powershell Try Catch Not Working in Application Integration</title>
    <link>https://community.hpe.com/t5/application-integration/powershell-try-catch-not-working/m-p/7040959#M1135</link>
    <description>In PowerShell some are stoppable and some are not-stoppable errors. The stoppable errors only raise exception otherwise not. But you can forcefully raise exception on error using '-ErrorAction Stop'.&lt;BR /&gt;&lt;BR /&gt;New-NSVolume  -name  .... ... etc -ErrorAction Stop'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Ravi</description>
    <pubDate>Wed, 03 Apr 2019 18:06:54 GMT</pubDate>
    <dc:creator>mamatadesaiNim</dc:creator>
    <dc:date>2019-04-03T18:06:54Z</dc:date>
    <item>
      <title>Powershell Try Catch Not Working</title>
      <link>https://community.hpe.com/t5/application-integration/powershell-try-catch-not-working/m-p/7039815#M1130</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I seem to be having an issue using Try/ Catch with the Nimble Powershell Module. I have done a lot of testing but the try never seems to go to catch on a terminating failure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EX:&lt;/P&gt;&lt;PRE&gt;    try{
        $newvol = New-NSVolume -name "$name" -size $size -perfpolicy 0316a3d10c4302926200000000000000000000001f -folder 2f16a3d10c43029262000000000000000000000001 -multi_initiator 1 
        Write-Host Created Volume $name
    } 
    catch {
        Write-Host failed to create volume $name
}&lt;/PRE&gt;&lt;P&gt;This will spit out a terminal error and kill the script without running the catch when I feed it a name of a volume that already exists. Am i doing something wrong here? I have used Try Catch before it just doesn't work with the Nimble module.&lt;/P&gt;&lt;P&gt;If anyone else has had this issue and found a workaround that would be helpful.&lt;/P&gt;&lt;P&gt;Edit: Added clarification.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 17:50:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/application-integration/powershell-try-catch-not-working/m-p/7039815#M1130</guid>
      <dc:creator>wave2453</dc:creator>
      <dc:date>2019-03-26T17:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Try Catch Not Working</title>
      <link>https://community.hpe.com/t5/application-integration/powershell-try-catch-not-working/m-p/7040667#M1134</link>
      <description>&lt;P&gt;I tried the similar code and seems the "Try-Catch" works for me....&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;STRONG&gt;My Powershell Script:&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;Connect-NSGroup -group 10.206.9.10 -credential admin -IgnoreServerCertificate&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;$name="Volume-Try-Catch"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;$size=10000&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;try&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;$newvol = New-NSVolume -name "$name" -size $size -perfpolicy 034ebc54516d750de1000000000000000000000014 -multi_initiator 1&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Write-Host Created Volume $name&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;catch {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Write-Host failed to create volume $name&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#339966"&gt;&lt;EM&gt;&lt;STRONG&gt;Script Output:&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;PS C:\Users\Administrator&amp;gt; Get-NSVolume&lt;/P&gt;&lt;P&gt;PS C:\Users\Administrator&amp;gt; Connect-NSGroup -group 10.206.9.10 -credential admin -IgnoreServerCertificate&lt;/P&gt;&lt;P&gt;$name="Volume-Try-Catch"&lt;BR /&gt;$size=10000&lt;/P&gt;&lt;P&gt;try&lt;BR /&gt;{&lt;BR /&gt;$newvol = New-NSVolume -name "$name" -size $size -perfpolicy 034ebc54516d750de1000000000000000000000014 -multi_initiator 1&lt;BR /&gt;Write-Host Created Volume $name&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;catch {&lt;BR /&gt;Write-Host failed to create volume $name&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Successfully connected to array 10.206.9.10&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#339966"&gt;&lt;EM&gt;Created Volume &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;Volume-Try-Catch&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;PS C:\Users\Administrator&amp;gt; Get-NSVolume&lt;/P&gt;&lt;P&gt;Name id Size vol_state perfpolicy_name thinly_provisioned block_size description&lt;BR /&gt;---- -- ---- --------- --------------- ------------------ ---------- -----------&lt;BR /&gt;Volume-Try-Catch 0651de34f45931ae3f000000000000000000000005 10000 online VMware ESX 5 True 4096&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS C:\Users\Administrator&amp;gt; Connect-NSGroup -group 10.206.9.10 -credential admin -IgnoreServerCertificate&lt;/P&gt;&lt;P&gt;$name="Volume-Try-Catch"&lt;BR /&gt;$size=10000&lt;/P&gt;&lt;P&gt;try&lt;BR /&gt;{&lt;BR /&gt;$newvol = New-NSVolume -name "$name" -size $size -perfpolicy 034ebc54516d750de1000000000000000000000014 -multi_initiator 1&lt;BR /&gt;Write-Host Created Volume $name&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;catch {&lt;BR /&gt;Write-Host failed to create volume $name&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Successfully connected to array 10.206.9.10&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#339966"&gt;failed to create volume &lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#993300"&gt;Volume-Try-Catch&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;PS C:\Users\Administrator&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 05:10:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/application-integration/powershell-try-catch-not-working/m-p/7040667#M1134</guid>
      <dc:creator>Thomas_Lam_HK</dc:creator>
      <dc:date>2019-04-02T05:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Try Catch Not Working</title>
      <link>https://community.hpe.com/t5/application-integration/powershell-try-catch-not-working/m-p/7040959#M1135</link>
      <description>In PowerShell some are stoppable and some are not-stoppable errors. The stoppable errors only raise exception otherwise not. But you can forcefully raise exception on error using '-ErrorAction Stop'.&lt;BR /&gt;&lt;BR /&gt;New-NSVolume  -name  .... ... etc -ErrorAction Stop'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Ravi</description>
      <pubDate>Wed, 03 Apr 2019 18:06:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/application-integration/powershell-try-catch-not-working/m-p/7040959#M1135</guid>
      <dc:creator>mamatadesaiNim</dc:creator>
      <dc:date>2019-04-03T18:06:54Z</dc:date>
    </item>
  </channel>
</rss>

