Powershell

How to Use the Invoke-Item (Microsoft.PowerShell.Management) Cmdlet in PowerShell?

In Windows, apps, files, images, or documents are normally launched using “File Explorer”. However, PowerShell can also be used to open files. For that purpose, the cmdlet “Invoke-Item” is utilized. This cmdlet is used to perform the automatic response to the mentioned item. “ii” is the default alias for the “Invoke-Item” cmdlet.

This tutorial will elaborate on the usage of PowerShell’s “Invoke-Item” cmdlet.

How to Use the PowerShell’s Invoke-Item Cmdlet?

The “Invoke-Item” cmdlet is responsible for invoking or opening files in PowerShell. To know more about the usage of the stated cmdlet, look at the mentioned examples.

Syntax

The syntax of the “Invoke-Item” cmdlet is provided below:

Invoke-Item [-Path] [-Filter] [CommonParameters]

Example 1: Use the “Invoke-Item” Cmdlet to Open a File

To open a file, first, use the “Invoke-Item” cmdlet, then assign the file path:

Invoke-Item "C:\Users\LinuxHint\Desktop\New.txt"

Example 2: Use the “Invoke-Item” Cmdlet to Open All Files of a Specific Type

To open all files of a specific type, simply assign the path along with the “*” asterisk and file extension to the “Invoke-Item” cmdlet:

Invoke-Item "C:\Users\LinuxHint\Desktop\*.txt"

That’s it! You have learned the usage of PowerShell’s “Invoke-Item” cmdlet.

Conclusion

To open the file in Powershell, the “Invoke-Item” cmdlet is used. Additionally, it is used to perform the default action on the specified item in PowerShell. For example, an image will open with whatever program it is associated with. This post has explained the usage of the “Invoke-Item” cmdlet in PowerShell.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.