Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7718725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:14:12+00:00 2026-06-01T03:14:12+00:00

In PowerShell you can use pushd (an alias for Push-Location ) and popd (an

  • 0

In PowerShell you can use pushd (an alias for Push-Location) and popd (an alias for Pop-Location) to push items onto and pop items off of a location stack.

This is very similar to bash’s pushd and popd functionality for a stack of directories.

But one other nice feature of bash is that you can use pushd all by itself to swap the top two locations on the stack. So you can flip back and forth very quickly between one location and another. And it also takes an argument like pushd +3 so you can swap with a location that’s a few elements down in your stack.

Is there any way to do this with PowerShell?

As an example, in bash:

$ pwd
/bin
$ pushd ~
~ /bin
$ pwd
/home/hopper
$ pushd
/bin ~
$ pwd
/bin
$ pushd
~ /bin
$ pwd
/home/hopper
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:14:13+00:00Added an answer on June 1, 2026 at 3:14 am

    There has been similar functionality built into the PowerShell Community Extensions for years 🙂 e.g.:

    48 >  cd C:\inetpub
    C:\inetpub
    49 >  cd C:\Windows\System32
    C:\Windows\System32
    50 >  cd -
    C:\inetpub
    51 >  cd +
    C:\Windows\System32
    52 >  cd
    
         # Directory Stack:
       --- ----------------
         0 C:\Users\Keith
         1 C:\inetpub
    ->   2 C:\Windows\System32
    
    53 >  cd -0
    C:\Users\Keith
    

    Although it isn’t quite a swap, the backward (-) and forward (+) metaphor is pretty well established these days. And you skip to any location in the location history by specifying -<num>. In fact, and this was a very handy addition suggested by a PSCX user, you can CD to a file file (which just cds to the dir the file is in) e.g.:

    cd $profile
    

    In order to enable this functionality in PSCX you have to specify the Pscx.UserPreference.ps1 file when you import the module e.g.:

    Import-Module PSCX -arg ~\Pscx.UserPreferences.ps1
    

    In this case, I copy the file from the PSCX dir to my home dir and modify to suit my tastes. For more info execute:

    cd -?
    

    or

    man cd -full
    

    The full source for this nested module is here (on CodePlex).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can display a simple Visual Basic inputbox from a PowerShell script like this:
Background this post explains how one can consume extension methods in Powershell http://community.bartdesmet.net/blogs/bart/archive/2007/09/06/extension-methods-in-windows-powershell.aspx Compare
We can use [Windows.Markup.XamlReader]::Load to load XAML file in PowerShell, but is there some
In PowerShell you can use [xml] to mean [System.Xml.XmlDocument]. Do you know where I
Using powershell, you can use the '&' character to run another application and pass
In PowerShell you can use the Get-WmiObject cmdlet to grab WMI classes. I have
Possible Duplicate: How can you use PowerShell's . (dot) notation to walk through elements
Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
I found that I can use $env:Path within PowerShell to see my current system
In powershell I can use the Format-Table command to sort everything in my results;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.