VMware PowerCLI

The Best User Interface for your VMware Datacenter!

Improve granularity for exceptions fired by PowerCLI cmdlets

Currently many PowerCLI cmdlets return a rather general VimException when something goes wrong.

Often the ErrorId and ErrorCategory provide more details on the exception that was fired.
But to improve error handling (in Try-Catch constructs) it would be easier to fire more specific exceptions instead of the general  VimException.

For example, a Get-VM -Name xyz, where the VM XYZ does not exist, returns a VimException and an ErrorCategory ObjectNotFound.
It would be more "PowerShell" friendly, to have in that case an exception of a type like VimException.ObjectNotFound.

  • Luc Dekens
  • Nov 11 2017
  • Attach files
  • William Lam commented
    November 13, 2017 16:40

    I would also extend this to CIS* cmdlets, often times you get very generic errors and it would be nice to plumb the full message from the underlying APIs, this is even more important for CIS cmdlets as they're mostly passthrough to the specific set of feature APIs (e.g. Content Library, Tagging, etc)