CmdID / PowerShell / Cmdlets / Set
Set-Location
Sets the current working location to a specified location. PowerShell reference
From the PowerShell reference
5 parameters
Aliases cd, chdir, sl
What it does
Sets the current working location to a specified location. The Set-Location cmdlet sets the working location to a specified location. That location could be a directory, a subdirectory, a registry location, or any provider path. You can also use the StackName parameter to make a named location stack the current location stack. For more information about location stacks, see the Notes.
Set-Location [[-Path] <String>] [-PassThru] [-UseTransaction] [<CommonParameters>]Set-Location -LiteralPath <String> [-PassThru] [-UseTransaction] [<CommonParameters>]Set-Location [-PassThru] [-StackName <String>] [-UseTransaction] [<CommonParameters>]
Set the current location
PS C:> Set-Location -Path "HKLM:\"
PS HKLM:>IdentifySet the current location and display that location
PS C:> Set-Location -Path "Env:\" -PassThruIdentifySet location to the current location in the C: drive
PS C:\Windows> Set-Location HKLM:\
PS HKLM:> Set-Location C:
PS C:\Windows>IdentifySet the current location to a named stack
PS C:> Push-Location -Path 'C:\Program Files\PowerShell\' -StackName "Paths"
PS C:\Program Files\PowerShell> Set-Location -StackName "Paths"
PS C:\Program Files\PowerShell> Get-Location -StackIdentifyIts page in the reference: Set-Location.
Parameters
-LiteralPathSpecifies a path of the location. The value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcard characters. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.-PassThruReturns a PathInfo object that represents the location. By default, this cmdlet does not generate any output.-PathSpecify the path of a new working location. If no path is provided, Set-Location defaults to the current user's home directory. When wildcards are used, the cmdlet chooses the container (directory, registry key, certificate store) that matches the wildcard pattern. If the wildcard pattern matches more than one container, the cmdlet returns an error.-StackNameSpecifies an existing location stack name that this cmdlet makes the current location stack. Enter a location stack name. To indicate the unnamed default location stack, type $null or an empty string ("").
Using this parameter does not change the current location. It only changes the stack used by the *-Location cmdlets. The *-Location cmdlets act on the current stack unless you use the StackName parameter to specify a different stack. For more information about location stacks, see the Notes.-UseTransactionIncludes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_Transactions.