PowerShell Logo Small

Push-Location



This is the built-in help made by Microsoft for the command 'Push-Location', in PowerShell version 2 - as retrieved from Windows version 'Microsoft® Windows Vista™ Ultimate ' 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 list of locations (a "stack").

SYNTAX


Push-Location [[-LiteralPath] <string>] [-PassThru] [-StackName <string>] [-UseTransaction] [<CommonParameters>]
Push-Location [[-Path] <string>] [-PassThru] [-StackName <string>] [-UseTransaction] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Push-Location cmdlet adds ("pushes") the current location to the top of a list of locations, called a "stack." You can push the current locat
ion onto a default stack or onto a stack that you create. If you specify a path, Push-Location pushes the current location onto the stack and the
n changes the current location to the location specified by the path. You cannot push a location onto the stack unless it is the current location
.



<

RELATED LINKS

Online version: http://go.microsoft.com/fwlink/?LinkID=113370
about_Providers
Pop-Location
Set-Location
Get-Location

REMARKS

<

Examples


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

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



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








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

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



Description
-----------
This command pushes the current location onto the RegFunction stack and changes the current location to the HKLM:\Software\Policies location. Thi
s command shows that you can use Push-Location with the Windows PowerShell registry provider.








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

C:\PS>push-location



Description
-----------
This command pushes the current location onto the default stack.








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

C:\PS>push-location ~ -stackname Stack2



Description
-----------
This 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. The Stack2 stack then becomes the current stack.