Collections:
Other Resources:
Get and Change Directory in Windows PowerShell
How to get and change the current directory of the file system in Windows PowerShell?
✍: FYIcenter.com
You can use the following cmdlets to get or change the current directory in a file system:
"Get-Location" cmdlet (or "pwd" alias) returns an object that represents the current directory, much like the pwd (print working directory) command.
"Set-Location" cmdlet (or "cd" alias) sets the working location to a specified directory in a file system.
"Push-Location" cmdlet adds ("pushes") the current location onto a location stack. If you specify a path, Push-Location pushes the current location onto a location stack and then changes the current location to the location specified by the path. You can use the Pop-Location cmdlet to get locations from the location stack.
"Pop-Location" cmdlet changes the current location to the location most recently pushed onto the stack by using the Push-Location cmdlet.
Here is a sample script on how to use cmdlets to manage the current location:
"I am here: "+(pwd) Push-Location Set-Location "C:\Windows\System32" "Now I moved to: "+(Get-Location) dir "*.hlp" Pop-Location "I am back: "+(pwd)
If you run the script, you will get:
PS C:\fyicenter> .\Test.ps1 I am here: C:\fyicenter Now I moved to: C:\Windows\System32 Directory: C:\Windows\System32 Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 6/10/2009 5:42 PM 10790 EDIT.HLP I am back: C:\fyicenter
⇒ Get Directory Entries in Windows PowerShell
⇐ What Is File System in Windows PowerShell
2016-10-27, 1879🔥, 0💬
Popular Posts:
What files are stored in the "C:\Users\<userid >\AppData\Local\M icrosoft\Windows\Tempor. ..
What is smss.exe process - Windows NT Session Manager? Process smss.exe is part of Windows system. I...
Setting Passwords in ZIP Files 1. Run WinZip and select menu File > New Archive. The "New Archive" d...
product key for adding features to windows 8 The product key you require is MBFBV-W3DP2-2MVKN-PJCQD- ...
What is the scheduled task "\Microsoft\Windows\RAC\ RacTask"on my Windows 7 computer? "\Microsoft\Wi...