VMware Cloud Community
jasonrobinson
Enthusiast
Enthusiast

Export of ErrorRecord Category Information

Is it possible to export all of the PowerCLI Error Category's and Category Reasons? I am trying to build some error handling into a script depending on the type of error produced. Here is an example of an error with the information I am looking for:

PS C:\> $test[0].CategoryInfo

Category   : InvalidArgument

Activity   : Get-VMHost

Reason     : ViServerConnectionException

TargetName :

TargetType :

Additionally is it possible to export all of the different Error Expection Types used by PowerCLI? For example: [VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.ViServerConnectionException]

Message was edited by: Jason Robinson

Jason @jrob24
Tags (2)
0 Kudos
1 Reply
ccalvetTCC
Enthusiast
Enthusiast

Maybe the following commands could be a starting point?

I guess all information are there somehow, but it is not that easy to dig into it.

(([appdomain]::currentdomain.GetAssemblies()).Modules  | where {$_.Name -match "vmware.vimautomation*"}).Assembly.modules.gettypes() | where {$_.Namespace -eq "VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException"} | select Name

((([appdomain]::currentdomain.GetAssemblies()).Modules  | where {$_.Name -match "vmware.vimautomation*"}).Assembly.modules.gettypes() | where {$_.Namespace -eq "VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException"} | where {$_.Name -eq "ViServerConnectionException"}).getmembers() | select name

#To be launched from a PowerCLI promt.

Blog: http://thecrazyconsultant.com/ | Twitter: @ccalvetTCC
0 Kudos