Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the Invoke-Item cmdlet launch an executable with parameters?

I'm trying to install some custom Windows services using PowerShell, and I've been unable to run InstallUtil without getting the following error:

A positional parameter cannot be found that accepts argument ''

Here's what I've run that causes the error above:

Invoke-Command -ComputerName <remote machine> -ScriptBlock {Invoke-Item C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe "<path to service exe>"}
like image 580
Scott Lawrence Avatar asked Aug 25 '10 17:08

Scott Lawrence


1 Answers

From the docs:

The Invoke-Item cmdlet performs the default action on the specified item.

I don't believe commandline arguments can be used with a default action.

However...

In this example, invoke-item shouldn't be necessary to invoke the executable.

Invoke-Command -ComputerName <remote machine> -ScriptBlock { C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe "<path to service exe>"}
like image 119
kbrimington Avatar answered Sep 30 '22 03:09

kbrimington