Contact Info

Crumbtrail » Administration » Powershell » Powershell 1.0 » Push-Location

Push-Location - Powershell 1.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.


Push a location to the stack


-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.

       Pass the object created through the pipeline. 
       By default, Pop-Location does not pass any objects through the pipeline.
       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.

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