- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use the Set-Location command in PowerShell?
Set-Location command in PowerShell is used to set the location of the drive from the current directory. The drive could be the local drive, folder path, shared path, registry, or any environmental variable.
This command is very useful while writing the script because many times we need multiple files from the same folder and each time we need to mention the full path. This command allows us to set the path at the beginning of the script and then we can directly browse the path from the current directly.
Example 1 − The below command sets the location from the C: to C:\Temp
PS C:\> Set-Location C:\Temp\ -PassThru Path ---- C:\Temp
Example 2 − The below command sets the location to the registry path from the current path.
PS C:\> Set-Location HKLM:\ PS HKLM:\>
Example 3 − The below command sets the location to the PSDrive from the current path.
PS C:\> Set-Location Env:\ PS Env:\>
PS C:\> Set-Location Cert:\ PS Cert:\>
- Related Articles
- How to use Push-Location and Pop-Location command in PowerShell?
- How to use the tree command in PowerShell?
- How to use the Timeout command in PowerShell?
- How to use Split-Path command in PowerShell?
- How to use the ConvertFrom-StringData command in PowerShell?\n
- How to use PowerShell Break statement with the Switch command?
- What is the use of Get-Process command in PowerShell?
- How to copy items from one location to another location using PowerShell?
- How to copy files/folders to the remote location in the PowerShell?
- How to run Invoke-Command in PowerShell Workflow?
- How to use Location API in Android to track your current location?
- How to convert command output to the Hashtable format in PowerShell?
- How to get/resolve the command from the alias in PowerShell?
- How to run PowerShell commands from the command prompt?
- How to pass arguments in Invoke-Command in PowerShell?