
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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:\>
Advertisements