Connect with us


Navigate the Windows folder structure using PowerShell




PowerShell uses several commands to navigate the Windows folder structure.

When you open a new PowerShell window, PowerShell typically starts in your user profile directory. For example, in Figure 1 you can see that the PowerShell prompt points to C:\Users\Brien. User profiles have a good location, but PowerShell operations often require navigating to different locations in the folder hierarchy. In my case, most of my PowerShell scripts live in a folder called C:\Scripts and are not accessible through my user profile folder.

Brian Posey

Figure 1. PowerShell often opens your user profile folder.

This article describes how to navigate the Windows folder structure using PowerShell.

drive switching

The first thing to know about PowerShell-based navigation is how to switch to another drive.

To change drives, type the drive letter you want to move to, followed by a colon. For example, in Figure 2, I typed Q: to switch from the C: drive to the Q: drive. Then I typed C: to go back to the C: drive.

Brian Posey

Figure 2. You can switch drives by typing a drive letter and a colon.

CD.. and CD\ commands

Most file system navigation involves traversing a directory structure. To move down one level in the directory hierarchy, type CD.. (note the double period).

Looking back at the previous two diagrams, you can see that PowerShell initially placed them in the C:\Users\Brien folder. Type CD.. and PowerShell will go to the C:\Users folder.

You can use the CD.. command to move through the folder hierarchy one level at a time, but it’s not always the most efficient method. For example, if you’re in the C:\Users\Brien folder and need to go to the root folder, you can enter the CD.. command twice as you did in Figure 3.

Brian Posey

Figure 3. Enter CD.. to go down one level in the folder hierarchy.

However, as a shortcut, you could enter the CD\ command. It immediately drops me in the root folder. Figure 4 shows an example.

Brian Posey

Figure 4. Entering CD\ takes PowerShell to the root directory.

As you can see, you can use the CD.. or CD\ commands to navigate to lower levels in the folder hierarchy. You can also use the CD command to enter the folder. Type CD followed by the folder name. If you are in the C:\Users folder and want to go to the Brien subfolder, you can type CD Brien.

PowerShell alias

Note that although this article discusses the CD command, CD is not an actual PowerShell command. In the days of DOS, CD was the command used to traverse the directory structure. Microsoft included support for the CD command in PowerShell as a shortcut and a way to bring PowerShell closer to DOS.

The CD command is called an alias.

In PowerShell, aliases are essentially just shortcuts. A short command that takes the place of a long command. The long command (PowerShell invokes the cmdlet) with CD as an alias is Set-Location.

The Set-Location cmdlet works just like the CD command, with one caveat. Unlike the CD command, you must include a space after the Set-Location cmdlet. CD.. is a valid command, but Set-Location.. is not. Instead, to avoid receiving the error, you should type:

Setting location ..

This can be seen in Figure 5.

Brian Posey

Figure 5. The CD command is an alias for Set-Location.

Get-ChildItem and DIR commands

There is another PowerShell cmdlet that can help when navigating the Windows folder structure. Get-ChildItem.

The Get-ChildItem cmdlet displays the contents of the current folder. Useful if you want to go to a subfolder but don’t know the exact folder name.

By the way, the Get-ChildItem cmdlet also has an alias. His alias is DIR, also from his DOS days. Back then, DIR was the DOS directory command. You can see how the DIR command works in Figure 6.

Brian Posey

Figure 6. You can see the contents of the current folder using the DIR command.

With that in mind, let’s say you had to navigate to the C:\Users\Brien\Desktop folder, but couldn’t remember the name of the desktop folder. You can navigate to C:\Users\Brien and use the DIR or Get-ChildItem cmdlets to see a list of all files and folders in that location. Then use that information to get the name of the folder you want (Desktop in this case) and use the CD command to navigate to that folder.




The mention sources can contact us to remove/changing this article

What Are The Main Benefits Of Comparing Car Insurance Quotes Online

LOS ANGELES, CA / ACCESSWIRE / June 24, 2020, / Compare-autoinsurance.Org has launched a new blog post that presents the main benefits of comparing multiple car insurance quotes. For more info and free online quotes, please visit https://compare-autoinsurance.Org/the-advantages-of-comparing-prices-with-car-insurance-quotes-online/ The modern society has numerous technological advantages. One important advantage is the speed at which information is sent and received. With the help of the internet, the shopping habits of many persons have drastically changed. The car insurance industry hasn't remained untouched by these changes. On the internet, drivers can compare insurance prices and find out which sellers have the best offers. View photos The advantages of comparing online car insurance quotes are the following: Online quotes can be obtained from anywhere and at any time. Unlike physical insurance agencies, websites don't have a specific schedule and they are available at any time. Drivers that have busy working schedules, can compare quotes from anywhere and at any time, even at midnight. Multiple choices. Almost all insurance providers, no matter if they are well-known brands or just local insurers, have an online presence. Online quotes will allow policyholders the chance to discover multiple insurance companies and check their prices. Drivers are no longer required to get quotes from just a few known insurance companies. Also, local and regional insurers can provide lower insurance rates for the same services. Accurate insurance estimates. Online quotes can only be accurate if the customers provide accurate and real info about their car models and driving history. Lying about past driving incidents can make the price estimates to be lower, but when dealing with an insurance company lying to them is useless. Usually, insurance companies will do research about a potential customer before granting him coverage. Online quotes can be sorted easily. Although drivers are recommended to not choose a policy just based on its price, drivers can easily sort quotes by insurance price. Using brokerage websites will allow drivers to get quotes from multiple insurers, thus making the comparison faster and easier. For additional info, money-saving tips, and free car insurance quotes, visit https://compare-autoinsurance.Org/ Compare-autoinsurance.Org is an online provider of life, home, health, and auto insurance quotes. This website is unique because it does not simply stick to one kind of insurance provider, but brings the clients the best deals from many different online insurance carriers. In this way, clients have access to offers from multiple carriers all in one place: this website. On this site, customers have access to quotes for insurance plans from various agencies, such as local or nationwide agencies, brand names insurance companies, etc. "Online quotes can easily help drivers obtain better car insurance deals. All they have to do is to complete an online form with accurate and real info, then compare prices", said Russell Rabichev, Marketing Director of Internet Marketing Company. CONTACT: Company Name: Internet Marketing CompanyPerson for contact Name: Gurgu CPhone Number: (818) 359-3898Email: [email protected]: https://compare-autoinsurance.Org/ SOURCE: Compare-autoinsurance.Org View source version on accesswire.Com:https://www.Accesswire.Com/595055/What-Are-The-Main-Benefits-Of-Comparing-Car-Insurance-Quotes-Online View photos


to request, modification Contact us at Here or [email protected]