- Community Home
- >
- Storage
- >
- HPE Nimble Storage
- >
- Application Integration
- >
- Powershell Try Catch Not Working
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2019 10:49 AM - edited 03-26-2019 10:50 AM
03-26-2019 10:49 AM - edited 03-26-2019 10:50 AM
Powershell Try Catch Not Working
Hi,
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.
EX:
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 }
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.
If anyone else has had this issue and found a workaround that would be helpful.
Edit: Added clarification.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2019 10:10 PM
04-01-2019 10:10 PM
Re: Powershell Try Catch Not Working
I tried the similar code and seems the "Try-Catch" works for me....
My Powershell Script:
Connect-NSGroup -group 10.206.9.10 -credential admin -IgnoreServerCertificate
$name="Volume-Try-Catch"
$size=10000
try
{
$newvol = New-NSVolume -name "$name" -size $size -perfpolicy 034ebc54516d750de1000000000000000000000014 -multi_initiator 1
Write-Host Created Volume $name
}
catch {
Write-Host failed to create volume $name
}
Script Output:
PS C:\Users\Administrator> Get-NSVolume
PS C:\Users\Administrator> Connect-NSGroup -group 10.206.9.10 -credential admin -IgnoreServerCertificate
$name="Volume-Try-Catch"
$size=10000
try
{
$newvol = New-NSVolume -name "$name" -size $size -perfpolicy 034ebc54516d750de1000000000000000000000014 -multi_initiator 1
Write-Host Created Volume $name
}
catch {
Write-Host failed to create volume $name
}
Successfully connected to array 10.206.9.10
Created Volume Volume-Try-Catch
PS C:\Users\Administrator> Get-NSVolume
Name id Size vol_state perfpolicy_name thinly_provisioned block_size description
---- -- ---- --------- --------------- ------------------ ---------- -----------
Volume-Try-Catch 0651de34f45931ae3f000000000000000000000005 10000 online VMware ESX 5 True 4096
PS C:\Users\Administrator> Connect-NSGroup -group 10.206.9.10 -credential admin -IgnoreServerCertificate
$name="Volume-Try-Catch"
$size=10000
try
{
$newvol = New-NSVolume -name "$name" -size $size -perfpolicy 034ebc54516d750de1000000000000000000000014 -multi_initiator 1
Write-Host Created Volume $name
}
catch {
Write-Host failed to create volume $name
}
Successfully connected to array 10.206.9.10
failed to create volume Volume-Try-Catch
PS C:\Users\Administrator>
Thomas Lam - Global Storage Field CTO
I work for HPE

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2019 11:06 AM
04-03-2019 11:06 AM
Re: Powershell Try Catch Not Working
New-NSVolume -name .... ... etc -ErrorAction Stop'
Regards
Ravi