Taking on PowerShell one cmdlet at a time

Share this post: This is part of an ongoing blog series by Adam Gordon. Adam will walk through each PowerShell command every week, explaining when and how to use them. Adam will be covering Invoke-Item this week.

When should you use Invoke-Item
The Invoke–Item cmdlet performs default actions on the specified item. It can open a document file, or run an executable file.
The default action depends upon the type of item. It is determined by the PowerShell provider who has access to the data.
What version of PowerShell do I use?
Get the PowerShell Version for your machine
This command displays the PowerShell version information for your machine.

How to use Invoke – Item?
Open a file
Invoke-Item “C:\PShellTest\Adam.txt”
This command opens “Adam.txt.” in Notepad. This command opens the file “Adam.txt” in Notepad.

All files of a particular type can be opened:
This command opens all.XML files in the C:PShellTest directory. Each document is opened in a different instance of Internet Explorer. In this instance, opening a.xml file in Internet Explorer is the default action.
Invoke-Item “C:\PShellTest\*.xml”

Learn the command last week: Get-PSProvider
Do you need PowerShell training? ITProTV offers PowerShell online IT training courses.