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.
https://p0w3rsh3ll.wordpress.com/2012/08/21/deciphering-error-codes/

I first tried Boe’s approach but it failed 😦

[ComponentModel.Win32Exception]0x80338104

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)

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s