Invoke-Item tips

Invoke-Item is another cmdlet that you don’t see used that often but there is one place where its invaluable – opening files. If you give Invoke-Item the path to a file

Invoke-Item -Path .\procs.txt

The file will be opened with the default application associated with that extension. In this case Notepad.

If you use a PowerShell script file

Invoke-Item .\t1.ps1

It will be opened in Notepad for you to examine.  CSV files automatically open in Excel and other Office files are opened in the correct application.

Using the alias ii for Invoke-item makes it even easier.

About these ads
This entry was posted in Powershell Basics. Bookmark the permalink.

One Response to Invoke-Item tips

  1. Martin says:

    I often use

    ii .

    to open an explorer window for the current folder.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s