Powershell Command : Set Location

Set-Location :

It was used to set the current working directory in the powershell.

Set-Location Description :

The Set-Location cmdlet was used to set the current working directory in the powershell. That location could be a directory, a sub-directory, a registry location. This is one of the most useful command in the powershell which will be used frequently by the programmers.

Set-Location Syntax :

Parameter Set: Path
Set-Location [[-Path] <String> ] [-PassThru] [-UseTransaction] [ <CommonParameters>]

Parameter Set: LiteralPath
Set-Location -LiteralPath <String> [-PassThru] [-UseTransaction] [ <CommonParameters>]

Parameter Set: Stack
Set-Location [-PassThru] [-StackName <String> ] [-UseTransaction] [ <CommonParameters>]

Set-Location Parameters :

-PassThru

It was used to return the objects that represents the location.

-LiteralPath<String>

It was used to specify the path to the loaction, the caluse which we are specifying as the literalpath parameter is used exactly as it is typed.

-Path<String>

Use to specify the path to the location.

-StackName<String>

The specified location stack is made as the current location stack.

-UseTransaction

Used for active transaction.

CommonParameters:

-Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, -OutVariable.

Set-Location Examples :

1) This command sets the location to the HKLM: drive.

PS C:> set-location HKLM:
PS HKLM:>

2) This command sets the location to the Env: drive

PS C:> set-location env: -passthru

Path
----
Env:
PS Env:>

3) This command sets the location to the C Drive.

PS C:> set-location C:

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *