< Back

Set-LocationEx

Sat Jan 18, 2020 9:47 am

NAME Set-LocationEx



SYNOPSIS

Set-Location replacement that maintains a location history, allowing easy navigation to previous locations.





SYNTAX

Set-LocationEx [[-Path] <String>] [-CopyToClipboard] [-PassThru] [-UseTransaction] [<CommonParameters>]



Set-LocationEx [-LiteralPath] <String> [-CopyToClipboard] [-PassThru] [-UseTransaction] [<CommonParameters>]



Set-LocationEx [-Backward] [-CopyToClipboard] [-PassThru] [-UseTransaction] [<CommonParameters>]



Set-LocationEx [-Forward] [-CopyToClipboard] [-PassThru] [-UseTransaction] [<CommonParameters>]



Set-LocationEx [-Id] <Int32> [-CopyToClipboard] [-PassThru] [-UseTransaction] [<CommonParameters>]





DESCRIPTION

Set-Location replacement that maintains a location history, allowing easy navigation to previous locations. The

location history contains the list of locations visited in the current PowerShell session. The location history

stores up to 100 locations.





PARAMETERS

-Path <String>

Specifies the path of a new working location. "." refers to the current location, ".." refers to the current

location's parent, "..." to that location's parent, and so forth. If the location is a leaf element (such as

the name of a file), the command will change to the location to the leaf element's container.



Required? false

Position? 1

Default value

Accept pipeline input? true (ByValue, ByPropertyName)

Accept wildcard characters? false



-LiteralPath <String>

Specifies the path of a new working location. This parameter used exactly as it is typed.



Required? true

Position? 1

Default value

Accept pipeline input? true (ByPropertyName)

Accept wildcard characters? false



-Backward [<SwitchParameter>]

Changes to the previous location in the location history. You can shorten this parameter name to "-b".



Required? true

Position? 1

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Forward [<SwitchParameter>]

Changes to the next location in the location history. You can shorten this parameter name to "-f".



Required? true

Position? 1

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Id <Int32>

Changes to the specified location Id in the location history. You can omit or shorten this parameter name to

"-i".



Required? true

Position? 1

Default value 0

Accept pipeline input? false

Accept wildcard characters? false



-CopyToClipboard [<SwitchParameter>]

Copies the current or new location to the clipboard. You can shorten this parameter name to "-c".



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-PassThru [<SwitchParameter>]

If changing locations, this parameter causes Set-LocationEx to return a PathInfo object that represents the

new location.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-UseTransaction [<SwitchParameter>]

If changing locations, this parameter causes Set-LocationEx to include the command in the active transaction.

This parameter is valid only when a transaction is in progress. For more information, see help

about_Transactions.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Set-LocationEx



Outputs the location history (same as Get-LocationHistory).









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Set-LocationEx ...



Changes two levels up from the current location. For example, if you are in

C:\\Windows\\System32\\WindowsPowerShell\\v1.0, this command will change to C:\\Windows\\System32.









-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Set-LocationEx 3



Changes to location Id 3 in the location history. Use Set-LocationEx without parameters or Get-LocationHistory to

see the location history. With only a location Id parameter, the -Id parameter name itself is optional.









-------------------------- EXAMPLE 4 --------------------------



PS C:\\>Set-LocationEx "10"



Changes to the location named "10" in the current location. Without the quotes, Set-LocationEx will interpret the

parameter as a location Id. You can also prefix the location with ".\\" to prevent Set-LocationEx from interpreting

the parameter as a location Id; e.g.: "Set-LocationEx .\\10".









-------------------------- EXAMPLE 5 --------------------------



PS C:\\>Set-LocationEx -Backward



Changes to the previous location in the location history.









-------------------------- EXAMPLE 6 --------------------------



PS C:\\>Set-LocationEx -Forward



Changes to the next location in the location history.









-------------------------- EXAMPLE 7 --------------------------



PS C:\\>Set-LocationEx -Id 15 -CopyToClipboard



Changes to location Id 15 and copies its path to the clipboard. The -CopyToClipboard parameter can also be

specified as -Clipboard (or -Clip, or just -c).









-------------------------- EXAMPLE 8 --------------------------



PS C:\\>Set-LocationEx $PROFILE



Changes to the parent location of the file named in the $PROFILE variable.









-------------------------- EXAMPLE 9 --------------------------



PS C:\\>Set-LocationEx -CopyToClipboard



Copies the current location to the clipboard.











RELATED LINKS