Open Current Folder in PowerShell

📜Part of the PowerShell Complete Guide, every PowerShell post on this site, grouped by the job you are doing.

When working in a PowerShell terminal session, you might want to open Windows Explorer to view the current directory.

This is a simple guide to demo how to open the current working directory directly from PowerShell.


Using Invoke-Item to Open the Current Folder

The Invoke-Item cmdlet lets you open files, folders, or other items. To open the current working directory in Windows Explorer, use a single . to reference the current path.

PowerShell
# Open current folder in windows explorer
Invoke-Item .
Invoke-Item PowerShell

You can also use the shorthand ii as an alias for Invoke-Item. This is helpful for quickly opening the current directory or a specified file path.

PowerShell
## ps script to open the current folder
write-output 'Opening current folder...' 
ii .
Run PowerShell script

Running this script will open the current directory in Windows Explorer after displaying a message, as shown in the screenshot above.

It works from wherever you are. Here cd $env:TEMP moves to the temp folder first, and ii . opens it in Explorer:

PowerShell
cd $env:TEMP
ii .
PowerShell: cd $env:TEMP then ii . opens a File Explorer window on the Temp folder

That’s it for this one, hope it was useful for you, cheers!

If SQL Server is part of your day job, my current work lives over at sqldba.blog: production DBA scripts, an error library and the SSMS guide.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *