PowerShell Logging / Error Handling



  • Ben Gibb

    Breaking it down to its simplest form:

    $Output = .\BiosConfigUtility64.exe /getvalue:"TPM Device"

    <BIOSCONFIG Version="" Computername="MyComputer" Date="2020/05/18" Time="10:05:01" UTC="10">
        <ERROR msg="System not supported. Unable to connect to HP WMI namespace: 'root\HP'/>
        <ERROR msg="BCU return value" real="23" translated="23" />

    [XML]$Output = .\BiosConfigUtility64.exe /getvalue:"TPM Device"

    Cannot convert value "System.Object[]" to type "System.Xml.XmlDocument". Error: "'<', hexadecimal value 0x3C, is an invalid attribute
    character. Line 3, position 2."
    At line:1 char:1
    + [XML]$Output = .\BiosConfigUtility64.exe /getvalue:"TPM Device"
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : MetadataError: (:) [], ArgumentTransformationMetadataException
    + FullyQualifiedErrorId : RuntimeException

    It appears that the tool doesn't return valid XML...
    Comment actions Permalink
  • Cody White

    Hmm, Thanks for the response Ben.

    I was working with support on this issue as well since I was not able to get output.log's. I narrowed this down to something similar.

    I didn't post my entire code but I am working on an error a bit higher up in sequence same error different switches for the exe. 

    [XML]$Output = .\BiosConfigUtility64.exe /npwdfile:default_password_1.bin

    The EXE would output

    <BIOSCONFIG Version="" Computername="#####" Date="2020/05/19" Time="12:19:30" UTC="-4">
      <ERROR msg="Unable to process command. Password is set, but no password file is provided" />
      <ERROR msg="BCU return value" real="10" translated="10" />


    This is where I was receiving weird error results in PDQ.

    After dumping all properties of $_ I was able to locate this error which was being suppressed by both PS/ISE at least on my computer.

    The specified node cannot be inserted as the valid child of this node, because the specified node is the wrong type.

    After Adjusting my code to

    [XML]$Output = .\BiosConfigUtility64.exe /npwdfile:default_password_1.bin | ConvertTo-Xml


    Everything is working as intended now.

    I hope the same can be said for

    $Output = .\BiosConfigUtility64.exe /getvalue:"TPM Device"


    I will post an update if this works for the TPM Device as well.


    Comment actions Permalink

Please sign in to leave a comment.