Capturing diskpart error code in powershell RRS feed

  • Question

  • Hi,

    I am trying to capture error code in powershell of the diskpart commands that I am firing in my script.

    I fire something like this

    "select disk' + " $rdisk" + '", "online disk" | diskpart

    , where $rdisk comes from any array of disk numbers.

    If the disk does not exist then I can read the error message on the STDOUT but $error.count remains 0 [Zero].

    How can I capture the error code?

    • Moved by Bill_Stewart Monday, March 2, 2015 8:29 PM Abandoned
    Friday, January 16, 2015 11:09 AM

All replies