Please feel free to provide feedback or file bugs here.

Remember last command output eg PSLastItem - forgot to assign object to variable

When you type in and run a cmdlet (especially one with side-effects) and forget to assign the output to a varialbe, it would be nice to be able to pick up the last output still stored in object form, from an automatic PS variable (eg PSLastItem) to feed into another command.
Example: running Start-Process with -PassThru, then wanting the ExitCode of the result which I forgot to assign. Maybe even re-use $_ as shorthand, because we're not in the pipeline?

2 votes
Sign in
(thinking…)
Password icon
Signed in as (Sign out)

We’ll send you updates on this idea

LUVoice shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

2 comments

Sign in
(thinking…)
Password icon
Signed in as (Sign out)
Submitting...
  • AdminJoey Aiello [MSFT] (Program Manager, Windows Server) commented  ·   ·  Flag as inappropriate

    I hear you. We just have to be very thoughtful about what we bring into the rest of PowerShell based on the amount that users will leverage it. Part of the reason that we did PowerShellGet is to allow you to bring in everything that you want, no matter how large or small. :)

  • LUVoice commented  ·   ·  Flag as inappropriate

    Thank you, just had a look, that's a great module - already thought of everything - except that it needs to be pre-installed and pre-loaded. And (although I will use that module in my own profile) I was hoping that something could operate without any thoughtful preparation - eg when we are supporting other 'clean' machines with default Powershell configuration.

Feedback and Knowledge Base