Get-LocationStack.ps1
19 Sep 2025Description
Purpose
Displays the current location stack.
Detailed Description
Shows all stored locations in the navigation stack.
Usage
Example 1
Get-LocationStack
Displays the stack of stored locations.
Notes
No additional notes.
Script
# Store the previous locations in a script-scoped stack
$script:locationStack = [System.Collections.Generic.Stack[string]]::new()
function Get-LocationStack {
<#
.SYNOPSIS
Displays the current location stack.
.DESCRIPTION
Shows all stored locations in the navigation stack.
.EXAMPLE
Get-LocationStack
Displays the stack of stored locations.
#>
[CmdletBinding()]
param ()
if ($script:locationStack.Count -eq 0) {
Write-Output "No locations in the stack."
} else {
Write-Output "Location Stack (most recent first):"
$script:locationStack.ToArray() | ForEach-Object { Write-Output " $_" }
}
}
Download
Please feel free to copy parts of the script or if you would like to download the entire script, simply click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.
Report Issues
You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.