Using the Invoke-Item Cmdlet

Opening a File or Running a Program

The Invoke-Item cmdlet provides a way to run an executable file or to open a file (or set of files) from within Windows PowerShell. For example, this command opens Calculator:

Invoke-Item c:\windows\system32\calc.exe

Note. Yes, by default you must specify the entire path to the executable file.

This command, meanwhile, opens all the .txt files found in C:\Scripts:

Invoke-Item c:\scripts\*.txt

To tell you the truth, the latter example - using Invoke-Item to open multiple items at once - is probably the best use of this cmdlet. If all you want to do is open a single document or launch a single program, that can be done just by typing the document/application name and pressing ENTER. Want to start Notepad? This command will do that for you:


Note. Interestingly enough, you don’t need to specify the entire file path if you start a program without actually calling Invoke-Item. Of course, that’s true only if the application is in your Windows path.

Want to open the file C:\Scripts\Test.txt in Notepad (or whatever program you use as the default editor for .txt files)? Then just type in the path to the file:

Invoke-Item Aliases
  • ii