Deciphering WinRM error codes

This morning I learned a nice tip from Shay Levy about Decoding WinRM error messages

I wanted to achieve the same thing without using the winrm.vbs file as vbscript isn’t allowed in my environment.
I opened the winrm vbscript and looked how the error code is translated.

The string is first converted to hexadecimal and then to a long integer.
Finally it uses a COM object to translate the error to a human readable error description.

I remembered that I’ve already worked on this hexadecimal to long integer conversion.

I first tried Boe’s approach but it failed 😦


Then I looked at this WSMan.Automation COMObject methods:

So I used my Get-ErrorCode function (available on this page) and got the expected result 🙂

(New-Object -ComObject WSMAN.Automation).GetErrorMessage(            
(Get-ErrorCode 0x80338104).Int64)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.