Share via


Using the Set-Location Cmdlet

The Set-Location cmdlet is roughly equivalent to the cd command found in Cmd.exe: it enables you to specify a new working location in a namespace. For example, this command sets the working location to C:\Scripts:

Set-Location c:\scripts

So why did we use clumsy terminology like working location rather than simply saying that Set-Location enables you to set the current working folder? That’s because, in Windows PowerShell, you aren’t limited to navigating through the file system (for more information, see the Get-PSDrive cmdlet). For example, this command places you in the HKEY_CURRENT_USER\Software\Microsoft\Windows portion of the registry:

Set-Location HKCU:\Software\Microsoft\Windows

Incidentally, not only can you use the alias cd as a shortcut method for calling Set-Location, but you can also use the commands cd .. to move to the parent location and cd \ to move to the drive root.

Set-Location Aliases
  • sl

  • cd

  • pwd

  • chdir