How to Open a Folder Using PowerShell
-
Use
Invoke-Item
Cmdlet to Open a Folder Using PowerShell -
Use
Start-Process
(Aliasstart
) to Open a Folder Using PowerShell -
Use the
explorer
Command to Open a Folder Using PowerShell -
Use
cmd.exe
With thestart
Command to Open a Folder Using PowerShell - Conclusion
PowerShell, a versatile scripting language and command-line shell for Windows, often requires working with files and folders. However, constantly switching between PowerShell and a graphical file explorer can be time-consuming.
Fortunately, PowerShell offers various methods to seamlessly manage folders and files without leaving the command line. This tutorial will guide you through the process of opening folders and files using PowerShell.
Use Invoke-Item
Cmdlet to Open a Folder Using PowerShell
The Invoke-Item
command performs the default action on the specified item. It’s particularly useful for opening folders and files, eliminating the need to switch to a graphical file explorer.
When a folder path is given, it opens that folder in the new File Explorer window.
# Open a specific folder
Invoke-Item C:\Users
If you provide .
as an argument will open the current working directory in File Explorer.
# Open the current working directory
Invoke-Item .
Similarly, you have to specify a file path to open a file. The following command opens a text.txt
file in the C:\New
directory.
# Open a file within a directory
Invoke-Item C:\Users\test.txt
There’s also an alias for Invoke-Item
called ii
, making it even quicker to open folders or files.
# Using the 'ii' alias
ii C:\Users
By using Invoke-Item
or it’s alias ii
, you can seamlessly interact with your file system without leaving the PowerShell environment.
Use Start-Process
(Alias start
) to Open a Folder Using PowerShell
Another method for opening folders in PowerShell is by using the Start-Process
cmdlet or its alias start
. It allows you to initiate processes, including opening folders, directly from the command line.
The following command opens a C:\Personal Website
folder on the computer.
# Open a specific folder
start 'C:\Users'
To open a current working directory, you can use .
.
# Open the current working directory
start .
With start
, you can swiftly access folders, even your current working directory, with ease.
Use the explorer
Command to Open a Folder Using PowerShell
Another way to open a folder from PowerShell is by using explorer
in the console. It simply opens the specified folder or file in the Windows File Explorer.
# Open a specific folder
explorer C:\Users\Public
You can also use .
to open the current folder in the File Explorer.
# Open the current folder
explorer .
The explorer
command provides a quick way to access your file system without switching to a separate file explorer window.
Use cmd.exe
With the start
Command to Open a Folder Using PowerShell
You can also use the cmd.exe
command with the start
command to open a folder or file. This approach allows you to use the same syntax as you would in the Command Prompt.
cmd.exe /c
runs the Command Prompt (cmd.exe
), and the /c
flag tells it to execute the start C:\Users
and then terminate.
# Open a specific folder
cmd.exe /c start C:\Users
This command will open the C:\Users
folder in the default file explorer.
Conclusion
In this tutorial, we’ve explored several methods for opening folders and files directly from PowerShell. By mastering these methods, you can efficiently navigate your file system and save valuable time during your scripting and administrative tasks.
We hope this article has equipped you with valuable skills for harnessing the power of PowerShell in managing your folders and files effectively.