Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
60 lines (45 sloc) 1.17 KB
layout title excerpt permalink tags categories published comments author_profile header gallery
single
Using $$, $^, $?
As requested by some of the User Group members, here are some of the variables that store state information for PowerShell. These variables are created and maintained by PowerShell.
powershell
exitcode
powershell
true
true
false
teaserlogo teaser image caption
images/headers/Code02_1920x500.jpg
image_path url title

As requested by some of the attendees of my user group, here are some example on how to use $$, $^, $?

$$

Contains the last token in the last line received by the current session.

Get-ChildItem -path "c:\windows\" -filter "*.log"

$$

Returns: *.log

$^

Contains the first token in the last line received by the session.

Get-ChildItem -path "c:\windows\" -filter "*.log"

$^

Returns: Get-ChildItem

$?

Contains the execution status of the last operation. It contains TRUE if the last operation succeeded and FALSE if it failed.

Get-ChildItem -path "c:\windows\" -filter "*.log"

$?

Returns: True