Push-Location

Push the current location onto the stack,and optionally change the current location. (pushd)

Syntax
      Push-Location { [[-path] string] | [-literalPath string] }
            [-stackName string] [-passThru] [-UseTransaction] [CommonParameters]

Key
   -path string
       Change your location to string after first pushing the 
       current location onto the stack. Wildcards are permitted.

   -literalPath string
       Like -Path above, only the value is used exactly as typed.
       No characters are interpreted as wildcards. If the path includes any
       escape characters then enclose the path in single quotation marks. 

   -stackName string
       An alternate stack. This stack now becomes the current stack.

   -passThru 
       Pass the object created through the pipeline. 
       By default, Pop-Location does not pass any objects through the pipeline.

   -UseTransaction
       Include the command in the active transaction.

Standard Aliases for Push-Location: pushd

Push-Location adds ("pushes") the current location to the top of a list of locations, called a "stack."
This can be the default stack or a stack that you create. If a path is specified, Push-Location will push the current location onto the stack and then change the current location to the new path.

Examples

Push the current location onto the default stack and then change location to C:\Windows\ :

PS C:\> push-location C:\Windows

Push the current location onto the stack and then change to the home directory (%USERPROFILE%), which can be represented by the tilde symbol (~) or $home:

PS C:\> push-location ~

Push the current location onto the 'myregstack' stack and change location to HKLM:\Software\Policies:

PS HKLM:\software> push-location HKLM:\Software\Policies -stackname myRegstack

#Ah, push it - push it good
Ah, push it - p-push it real good# ~ Salt 'N' Pepa

Related PowerShell Cmdlets

Pop-Location - Set the current working location (from the stack).
Equivalent bash command:pushd - Save and then change the current directory.


 
Copyright © 1999-2024 SS64.com
Some rights reserved