PowerShell Logo Small

Push-Location



This is the built-in help made by Microsoft for the command 'Push-Location', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Adds the current location to the top of a location stack.

SYNTAX


Push-Location [[-Path] [<String>]] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String>]]
[-PassThru] [-StackName [<String>]] [-UseTransaction [<SwitchParameter>]] [<CommonParameters>]
Push-Location [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String>]] [-LiteralPath [<String>]]
[-PassThru] [-StackName [<String>]] [-UseTransaction [<SwitchParameter>]] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


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.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=293892
Get-Location
Pop-Location
Set-Location
about_Providers

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

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



This command pushes the current location onto the default location stack and then changes the location to C:\Windows.










-------------------------- EXAMPLE 2 --------------------------

PS C:\>push-location HKLM:\Software\Policies -stackname RegFunction



This command pushes the current location onto the RegFunction stack and changes the current location to the HKLM:\Software\Policies location. You can use the Location
cmdlets in any Windows PowerShell drive (PSDrive).










-------------------------- EXAMPLE 3 --------------------------

PS C:\>push-location



This command pushes the current location onto the default stack. It does not change the location.










-------------------------- EXAMPLE 4 --------------------------

PS C:\>push-location ~ -stackname Stack2
PS C:\Users\User01> pop-location -stackname Stack2
PS C:\>



These commands show how to create and use a named location stack.

The first command pushes the current location onto a new stack named Stack2, and then changes the current location to the home directory (%USERPROFILE%), which is
represented in the command by the tilde symbol (~) or $home. If Stack2 does not already exist in the session, Push-Location creates it.

The second command uses the Pop-Location cmdlet to pop the original location (PS C:\>) from the Stack2 stack. Without the StackName parameter, Pop-Location would pop the
location from the unnamed default stack.

For more information about location stacks, see the Notes.