Skip to main content

Command referenceSet-Location

Set-Location command (Windows / PowerShell)

WindowsPowerShellfilebeginner

What it does

Change the current location to a path in a PowerShell provider. Guides covering the set-location powershell usually need pipeline-friendly examples, common parameters, and how the cmdlet compares with classic CMD or Linux tools. This page includes syntax, options, and copyable PowerShell examples.

Change the current location to a path in a PowerShell provider.

Syntax

Set-Location [[-Path] <String>] [-PassThru] | Set-Location -LiteralPath <String> [-PassThru]

Common options

Flag / optionMeaning
-PathSet a path with wildcard interpretation.
-LiteralPathUse the supplied path exactly.
-PassThruReturn the new location object.
-StackNameSelect a named location stack.

Practical examples

Open project

Set-Location C:\Projects\Site

Changes the filesystem working location.

Literal brackets

Set-Location -LiteralPath 'C:\Data\[Current]'

Treats brackets as ordinary characters.

Change registry drive

Set-Location HKCU:\Software

Moves into the registry provider.

Linux ↔ Windows equivalent

Closest match: cd (Linux / bash / sh / zsh). Change the shell's current working directory.

Common mistakes

  • Forgetting that wildcard characters in `-Path` are interpreted.
  • Assuming location changes in a child PowerShell process affect its parent.

FAQ

What does Set-Location do in PowerShell?

Change the current location to a path in a PowerShell provider.

How can I see examples for Set-Location?

Run `Get-Help Set-Location -Examples`, then adapt an example to the provider and objects you are using.

What is a practical Set-Location example?

Try `Set-Location C:\Projects\Site` — Changes the filesystem working location.

Does Set-Location return text or objects?

Set-Location normally participates in PowerShell's object pipeline; formatting seen in the console is a view of those objects.

Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.