CmdID / PowerShell / Cmdlets / Push
Push-Location
Adds the current location to the top of a location stack. PowerShell reference
From the PowerShell reference
5 parameters
Alias pushd
What it does
Adds the current location to the top of a location stack. The Push-Location cmdlet adds ("pushes") the current location onto a location stack. If you specify a path, Push-Location pushes the current location onto a location stack and then changes the current location to the location specified by the path. You can use the Pop-Location cmdlet to get locations from the location stack. By default, the Push-Location cmdlet pushes the current location onto the current location stack, but you can use the StackName parameter to specify an alternate location stack. If the stack does not exist, Push-Location creates it. For more information about location stacks, see the Notes.
Push-Location [[-Path] <String>] [-PassThru] [-StackName <String>] [-UseTransaction] [<CommonParameters>]Push-Location [-LiteralPath <String>] [-PassThru] [-StackName <String>] [-UseTransaction] [<CommonParameters>]
Example 1
PS C:> Push-Location C:\WindowsIdentifyExample 2
PS C:> Push-Location HKLM:\Software\Policies -StackName RegFunctionIdentifyExample 3
PS C:> Push-LocationIdentifyExample 4 - Create and use a named stack
PS C:> Push-Location ~ -StackName Stack2
PS C:\Users\User01> Pop-Location -StackName Stack2
PS C:>IdentifyIts page in the reference: Push-Location.
Parameters
-LiteralPathSpecifies the path to the new location. Unlike the Path parameter, the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.-PassThruPasses an object representing the location to the pipeline. By default, this cmdlet does not generate any output.-PathChanges your location to the location specified by this path after it adds (pushes) the current location onto the top of the stack. Enter a path to any location whose provider supports this cmdlet. Wildcards are permitted. The parameter name is optional.-StackNameSpecifies the location stack to which the current location is added. Enter a location stack name. If the stack does not exist, Push-Location creates it.
Without this parameter, Push-Location adds the location to the current location stack. By
default, the current location stack is the unnamed default location stack that PowerShell creates.
To make a location stack the current location stack, use the StackName parameter of the
Set-Location cmdlet. For more information about location stacks, see the Notes.
NOTE:
Push-Location cannot add a location to the unnamed default stack unless it is the current
location stack.-UseTransactionIncludes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_Transactions.