Solved

PowerShell Tab Completion for External Commands (MSIEXEC.EXE in particular)

Posted on 2015-01-05
3
111 Views
Last Modified: 2015-01-21
When using PowerShell, either the console or ISE (as a shell - I'm not concerned with scripting for this question), how does one tab complete when using an external command so that .\ is NOT placed in front of your argument.

So my specific example is this: I am a Setup Developer. I use msiexec.exe all the time..

So to test my packages I go to (instead of CMD prompt) PowerShell and type say something like:

(assume testpackage.msi is in my current directory)

PS C:\Packages\TestPackageFolder> msiexec.exe /i  test <hit tab complete here and I get>

PS C:\Packages\TestPackageFilder> msiexec.exe /i .\testpackage.msi

Now, msiexec.exe has no idea what .\testpackage.msi means and can't find testpackage.msi - Therefore I have to backspace and delete .\ so that finally I get

PS C:\Packages\TestPackageFilder> msiexec.exe /i testpackage.msi

THAT works.

I get that PowerShell needs an absolute or relative path, but my external commands, especially msiexec.exe which is my bread and butter does not.

I tried & at the beginning of the command like:

PS C:\Packages\TestPackageFilder>  & msiexec.exe /i .\testpackage.msi

but that makes no difference - tab complete still appends .\

Going nuts.. Want to learn PowerShell and abandon CMD.exe but as you can imagine, since I run the above command probably 100 times a day I'm losing time and productivity.

Any help is appreciated! Thanks!
0
Comment
Question by:Jim Fitzgerald
3 Comments
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
Comment Utility
Interesting.  MsiExec does not recognise a valid path.
No, there is no way to suppress the relative path notation if using tab completion in PowerShell.
0
 
LVL 53

Expert Comment

by:Will Szymkowski
Comment Utility
If you are running it strictly as a script file .ps1 then as Qlemo said you cannot. If you are actually using the cmdletbinding and using the .psm1 (module) extension then when you import your module into the powershell session you can Tab complete just like other native cmdlets.

Example
script file name get-user.psm1
function get-user
import-module .\get-user.psm1

Now when you do get-module you will see your module in the PS session

You can then Tab complete get-u >Tab = get-user

Will.
0
 

Author Closing Comment

by:Jim Fitzgerald
Comment Utility
Thanks for confirming that this is impossible.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Why would I want to create a function for tracking messages? I am glad you asked. As with most monotonous/routine tasks, human error tends to creep in after doing the same task over and over again. By creating a function, you load the function once…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now