Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate Command line argument

I get an error saying that I have a duplicate command line argument... anyone know why this would be happening and what would be the work-around?

enter image description here

$fileServer = 'server.contoso.local'
$MediaPath = "\\$fileServer\Deployment\Software\AppFabric\"
$MediaName = "WindowsServerAppFabricSetup_x64_6.1.exe"


$cmd = Join-Path $MediaPath -ChildPath $MediaName
$cmd += " /install CachingService , CacheClient , CacheAdmin /SkipUpdates /logfile "
$cmd += " F:\Logs\AppFabric\AppFabricInstallLog.txt "
Invoke-Expression -Command $cmd

Here is the output of the $cmd:

\\server.contoso.local\Deployment\Software\AppFabric\WindowsServerAppFabricSetup_x64_6.1.exe /i CachingService , CacheClient , CacheAdmin /SkipUpdates /logfile  F:\Logs\AppFabric\AppFabric\InstallLog.txt 

enter image description here

I have narrowed it down to the arguments that are called after the installer. "CachingService , CacheClient , CacheAdmin". Everything else works if I remove "CachingService , CacheClient , CacheAdmin"

One more note to add... if I run this exact same command in CMD.exe it will work just fine. However, my task is automating in PowerShell using DSC (Desired State Configuration)


2 Answers

If I run your command through echoargs.exe (utility from the PowerShell Community Extensions) I see that the commas are stripped out:

C:\PS> echoargs /i CachingService , CacheClient , CacheAdmin /SkipUpdates /logfile  F:\Logs\AppFabric\AppFabric\InstallLog.txt
Arg 0 is </i>
Arg 1 is <CachingService>
Arg 2 is <CacheClient>
Arg 3 is <CacheAdmin>
Arg 4 is </SkipUpdates>
Arg 5 is </logfile>
Arg 6 is <F:\Logs\AppFabric\AppFabric\InstallLog.txt>

Command line:
"C:\Program Files (x86)\PowerShell Community Extensions\Pscx3\Pscx\Apps\EchoArgs.exe"  /i CachingService CacheClient CacheAdmin /SkipUpdates /logfile F:\Logs\AppFabric\AppFabric\InstallLog.txt

If you are using PowerShell V3 or higher, use the --% to put PowerShell into simplified (dumb) argument parsing mode e.g.:

$cmd += " --% /install CachingService , CacheClient , CacheAdmin /SkipUpdates /logfile "

The link for the community extensions is http://pscx.codeplex.com. If you're trying out the PowerShell 5.0 preview you can install it from the PSGet gallery.

like image 127
Keith Hill Avatar answered Aug 03 '26 07:08

Keith Hill


For resolving issues installing prerequisites for SharePoint 2016 or 2013 I used the following script to bypass the mentioned duplicate command error (in Windows 2012 R2)

C:\>.\WindowsServerAppFabricSetup_x64.exe/i CacheClient","CachingService","CacheAdmin /gac
like image 23
Iman Avatar answered Aug 03 '26 05:08

Iman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!