Search code examples
powershellappfabricdsc

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)


Solution

  • 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.