Push-Location - PowerShell command help and examples

Adds the current location to the top of a list of locations (a "stack"). (Push-Location)


NAME
Push-Location
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>]
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 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 the current location to the location specified by the path. You cannot push a location onto the stack unless it is the current location.
PARAMETERS
-LiteralPath <string> Specifies 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 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 -PassThru [<SwitchParameter>] Passes an object representing the location to the pipeline. By default, this cmdlet does not generate any output. Required? false Position? named Default value Accept pipeline input? false Accept wildcard characters? false -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 Accept pipeline input? true (ByValue, ByPropertyName) Accept wildcard characters? false -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 -UseTransaction [<SwitchParameter>] Includes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_Transactions. Required? false Position? named Default value Accept pipeline input? false Accept wildcard characters? false <CommonParameters> This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer and OutVariable. For more information, type, "get-help about_commonparameters".
INPUTS
System.String You can pipe a string that contains a path (but not a literal path) to Push-Location.
OUTPUTS
None or System.Management.Automation.PathInfo When you use the PassThru parameter, Push-Location generates a System.Management.Automation.PathInfo object that represents the location. Otherwise, this cmdlet does not generate any output.
NOTES
You can also refer to Push-Location by its built-in alias, "pushd". For more information, see about_Aliases. A "stack" is a "last-in, first-out" (LIFO) data structure. It is like a vertical list in which only the top item is accessible. You can add ("push") items only to the top of the stack, and you can retrieve ("pop") items only from the top of the stack. To get to items below the top, you must retrieve all the items above. The Push-Location cmdlet is designed to work with the data exposed by any provider. To list the providers available in your session, type "Get-PSProvider". For more information, see about_Providers.

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. This 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. RELATED LINKS Online version: http://go.microsoft.com/fwlink/?LinkID=113370 about_Providers Pop-Location Set-Location Get-Location C:\Windows>powershell get-help Pop-Location -full

Microsoft Windows [Version 10.0.19045.3693]
Copyright (c) 2023 Microsoft Corporation.

ColorConsole [Version 3.7.1000] PowerShell 2.0-Export

Windows 11, 10, 8.1, 8, 7 / Server 2022, 2019, 2016











Windows-10


... Windows 10 FAQ
... Windows 10 How To


Windows 10 How To


... Windows 11 How To
... Windows 10 FAQ



PowerShell: Adds the current location to the top of a list of locations (a "stack").

HTTP: ... PS_Windows/en/Push-Location.htm
0.124
16885
Hardware sicher entfernen als Windows 11 Desktop-Verknüpfung? Wie kann man das Programm schneller zu Tray minimieren? Surf and work with a guest account rather than with a standard user under Windows 11! Gibt es einen Unterschied zwischen Dateiverwaltung und Dateimanagement? Should I hack Windows 11 for unsupported PCs? Kann ich E-Mails per Tastenkürzel versenden? Window always on top on Windows 11? Windows 11 parallel to 10, how can I switch between them!? Position vom aktuellen Datum im Kalender einstellen? Different line breaks use CR LF, LF, CR when inserting plain text?



(0)