I had the need to write a script that make some directories changes but at the exit came back to the current directory where I ran it.
The pushd command saves the current working directory so it can be returned to at any time, optionally changing to a new directory. The popd command returns to the path at the top of the directory stack.
In Windows PowerShell, pushd is a predefined command alias for the Push-Location cmdlet and popd is a predefined command alias for the Pop-Location cmdlet.
This directory stack is accessed by the command Get-Location -stack in Windows PowerShell.
pushd and popd is available also on windows command prompt (CMD) and Linux bash.
PS C:\> pushd .\Data\Working\ PS C:\Data\Working> Get-Location -Stack Path ---- C:\ PS C:\Data\Working> popd PS C:\>