3

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)

  • Well, the first thing to try is simply echoing `$cmd` before passing it to `Invoke-Expression` to see exactly what it contains, I'd think. The second thing I think I'd do is [edit] your question to include the **exact** error message you're seeing, rather than just "an error saying that I have a duplicate command line argument" so we can see if there is additional information in the error that might help. – Ken White Jul 11 '14 at 19:28
  • Thank you, Ken! I have updated the question with your suggestions. –  Jul 11 '14 at 19:33
  • I don't see anything glaringly wrong, which means it's probably in one of the switches (you have a mix of `-` and `/` switch characters, so I'm not sure which one might be it). Did you try running `WindowsServerAppFabricSetup_x64_6.1.exe /?` from the command line as the dialog suggested to see what might be a conflict or duplicate? – Ken White Jul 11 '14 at 19:42
  • Thank you for the follow up, Ken! I have done that already. For other memebers that may want to see the installation commands I updated the question with the output using the /? –  Jul 11 '14 at 19:45
  • 1
    Does it work if you remove the spaces from `CachingService , CacheClient , CacheAdmin`, i.e. use `CachingService,CacheClient,CacheAdmin`? – Andrew Morton Jul 11 '14 at 19:50
  • Thank you, Andrew! No, it makes no difference if I remove the spaces. –  Jul 11 '14 at 19:50
  • Same issue happens if this command is run interactively from PowerShell. A workaround is to run via an elevated Windows command prompt. – Underverse Feb 12 '17 at 10:46

2 Answers2

3

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.

Keith Hill
  • 194,368
  • 42
  • 353
  • 369
  • Thank you, Keith! I gave it a shot and it seems to do the same thing. I like the EchoArgs.exe. I've never heard of that but it's an excellent tool. –  Jul 11 '14 at 20:46
  • What version of PowerShell are you on? – Keith Hill Jul 11 '14 at 21:48
2

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
Iman
  • 17,932
  • 6
  • 80
  • 90