Command referenceSet-Location
Set-Location command (Windows / PowerShell)
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 / option | Meaning |
|---|---|
| -Path | Set a path with wildcard interpretation. |
| -LiteralPath | Use the supplied path exactly. |
| -PassThru | Return the new location object. |
| -StackName | Select 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.
Related commands
- Get-ChildItemEnumerate items and child items in filesystem, registry, and other providers.
- Get-CommandDiscover commands, aliases, functions, scripts, and applications available to PowerShell.
- cdDisplay or change the current directory in Command Prompt.
- lsList directory entries and inspect file metadata.
- cdChange the shell's current working directory.
- dirList files and subdirectories with names, dates, sizes, and attributes.
- findWalk directory trees and select entries using tests and actions.
- rmRemove files and directory trees permanently.
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.