PowerShell: Is there an automatic variable for the last execution result?

前端 未结 10 1875
名媛妹妹
名媛妹妹 2021-02-05 00:29

I\'m looking for a feature comparable to Python interactive shell\'s \"_\" variable. In PowerShell I want something like this:

> Get-Something # this returns          


        
10条回答
  •  孤独总比滥情好
    2021-02-05 01:07

    You can also print the result of the command and capture the output object(s) using the OutVariable parameter, later on then use $anObj to display the variable content.

    Get-Something -OutVariable anObj
    

提交回复
热议问题