Author Posts

October 20, 2013 at 4:38 am

Hi I am new to powershell and I am having a problem running a script that I have modified to install software from my usb key

The USB key is a 64 GB stick partitioned into four drives w:, x:, y: and z:

I am running this script

Function Install-Software
{
PARAM
(
$file = "Z:\scripts\Adobe Photoshop CS6 Extended\SOFTWARE\Set-up.exe",
$Arguments ='/q CONTENT_DIR="Z:\scripts" DEFAULT_WEBSITE=0 CONTENT_LOCAL=1'
)

$Install = Start-Process $File -ArgumentList $Arguments -Wait -PassThru

If($Install.ExitCode -eq 0){
Write-Host "Installation was OK" -ForegroundColor GREEN
}
Else
{
Write-Host "Installation failed $("$Install.ExitCode")" -ForegroundColor RED
}

}

No matter what I do I always get this error:

PS Z:\Scripts> .\script.ps1
Missing ')' in function parameter list.
At Z:\Scripts\Script.ps1:4 char:13
+ $Z: < <<< \scripts\Adobe Photoshop CS6 Extended\SOFTWARE\Set-up.exe + CategoryInfo : ParserError: (CloseParenToken:TokenId) [], Parse Exception + FullyQualifiedErrorId : MissingEndParenthesisInFunctionParameterList PS Z:\Scripts>

But as you can see there is definately a ) there. I know it is just a simple syntax error but blowed if I can find out what is wrong with this script

Any help would be great

Tim

October 20, 2013 at 5:44 am

It looks fine to me, except for the "smart quotes" that the forum software automatically inserts when you post code outside of a CODE or PRE block. When I replaced all of those with normal single and double quotation marks, the function executed without any errors regarding the param block:

Function Install-Software
{
    PARAM
    (
        $file = 'Z:\scripts\Adobe Photoshop CS6 Extended\SOFTWARE\Set-up.exe',
        $Arguments ='/q CONTENT_DIR="Z:\scripts" DEFAULT_WEBSITE=0 CONTENT_LOCAL=1'
    )

    $Install = Start-Process $File -ArgumentList $Arguments -Wait -PassThru

    If($Install.ExitCode -eq 0){
        Write-Host "Installation was OK" -ForegroundColor GREEN
    }
    Else
    {
        Write-Host "Installation failed $("$Install.ExitCode")" -ForegroundColor RED
    }
}