How to open any file with its default application with PowerShell?

To open any file using its default application, we can use the Invoke-Expression command. For example, we want to open a file on the C:\temp and the file name is NewUsers.CSV then you can run the below command.

Invoke-Expression C:\Temp\NewUsers.csv

The above command will open the file from that location. If the default application is not set then Windows will ask for the default application to select.

If you know any application name and which can be opened with the shortcut then you can directly type the name of the application. For example, Notepad.exe, Calc.exe

Generally, they can be opened directly but this command also helps to open the application as shown below.

PS C:\> Invoke-Expression notepad.exe
PS C:\> Invoke-Expression calc.exe

Updated on: 20-Nov-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started