VMware Cloud Community
jvm2016
Hot Shot
Hot Shot
Jump to solution

try_catch_powercli

hi luc ,

vm abc does not exist in inventory .so it will throw error (exception) and will force to run catch block

am i supposed to get checking exception text through catch block

pastedImage_0.png

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You should add -ErrorAction Stop to get a terminating exception and this land in the catch block.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

You should add -ErrorAction Stop to get a terminating exception and this land in the catch block.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

thanks it is working.

0 Kudos