When I run the following code in the console it returns the desired output:
get-hotfix | format-wide -property "hotfixid" -column 7
Returning just the KB name in 7 columns. I'm running a script that gathers evidence of security hardening for our servers and it takes a screenshot of the patches.
But when I run it inside of a script with other pieces of code it returns the error:
$patches = get-hotfix
Take-ScreenShot -activewindow -file $pwd\Evidence\$svr\step2_$svr.jpg -imagetype jpg
$service = get-service
Once a script starts spewing the output of a Format command to the pipeline, the pipeline goes into "screen display mode," and it can't "take" anything else. In other words, once you format something, you're done. Don't produce any other output.
Alternately, you could pipe Format-Wide to something like Out-File, which would give you the text you want, but potentially allow other output from your script as well.
Format commands are a PITA sometimes.
Ah, I knew there were some issues with formating, but I thought it always meant no more commands in the pipe, not the whole script ;x
I've resolved it like you said by out-file -ing to a .txt then 'cat .\file.txt' and taking a screenshot while it's on screen.
Thanks again for the advice!
You must be logged in to reply to this topic.