Push-Location

 

SYNOPSIS

Pushes the current location onto the stack.

 

SYNTAX

Push-Location [[-path] <string>] [-stackName <string>] [-passThru] [<CommonParameters>]

 

Push-Location [[-literalPath] <string>] [-stackName <string>] [-passThru] [<CommonParameters>]

 

DETAILED DESCRIPTION

The Push-Location cmdlet pushes the current location 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 then changes to the location specified by the path. You cannot push a location onto the stack unless it is the current location.

 

PARAMETERS

 

-path <string>

Changes 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 ("-Path") is optional.

 

Required?

false

Position?

1

Default value

<NOTE: if not specified uses the Current location>

Accept pipeline input?  

true (ByValue, ByPropertyName)

Accept wildcard characters? 

true

 

-stackName <string>

Specifies the name of a stack. The current location is pushed onto this stack, and this stack becomes the current stack. If the stack does not yet exist, it is created.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

true (ByPropertyName)

Accept wildcard characters? 

false

 

-passThru <SwitchParameter>

Passes the object created by this cmdlet through the pipeline. By default, this cmdlet does not pass any objects through the pipeline.

 

Required?

false

Position?

named

Default value

False

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-literalPath <string>

Specifies the path to the new location. Unlike Path, the value of LiteralPath 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 Windows PowerShell not to interpret any characters as escape sequences.

 

Required?

false

Position?

1

Default value

 

Accept pipeline input?  

true (ByPropertyName)

Accept wildcard characters? 

false

 

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. For more information, type, "get-help about_commonparameters".

 

NOTES

 

For more information, type "Get-Help Push-Location -detailed". For technical information, type "Get-Help Push-Location -full".

 

When specifying multiple values for a parameter, use commas to separate the values. For example, "<parameter-name> <value1>, <value2>".

 

You can also refer to Push-Location by its built-in alias, "pushd". For more information, see About_Alias.

 

EXAMPLE 1

 

push-location C:\Windows

 

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

 

EXAMPLE 2

 

push-location HKLM:\Software\Policies -stackname RegFunction

 

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

 

EXAMPLE 3

 

push-location

 

This command pushes the current location onto the default stack.

 

EXAMPLE 4

 

push-location ~ -stackname Stack2

 

This command pushes the current location onto a new stack named Stack2 and then changes to the home directory (%USERPROFILE%), which is represented in the command by the tilde symbol (~) or $home. The Stack2 stack now becomes the current stack.

 

RELATED LINKS

Pop-Location

Set-Location

Get-Location