I'm running a vagrant
winrm command, and am noticing that a command that fails doesn't print out the entire error output... I thought |
might be used to expand output from such commands... but after some internet searching, and trying a few options, such as:
| fl
| Format-Table -Wrap -Au
I still get a ...
in the final output of
my error message, i.e. in the part where the command is echo'd.
NewItemIOError
At line:1 char:1
+ New-Item -path C:\var\lib\kubelet\etc\kubernetes\pki\ -type SymbolicL ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The above failure is happening for a clear and obvious reason, so I don't need help debugging the issue, but rather, am generally wondering what is the right option to use with New-Item
to make sure powershell shows me the entire output of its failed execution in automated environments with 10000s of lines of logs.
What's the simplest way to output verbose error messages from new-item, and similar powershell commands?
Simply put - dots in exception message in console are only for display purposes - to not give you wall of text. If you want to display the FULL exception you can use something like this:
This displays info like below and gives you full info about Exception object :)
For full message or stack trace, just go with
$_.Exception.Message
or$_.Exception.StackTrace
:and it gives info:
PS. If you want even more info:
This will display all the info including ScriptStackTrace (at which line the exception occurred):