Help with argument containing space

Hi, I’m working on a script, where i need to import userprofiles from a profile archive to be terminated, to a new profile area during login. This will be running as a logon task with Horizon Vmware DEM.

This Script works, because there is no space in chrome.zip:

$ProfArchPath = @()
$ProfArchPath = (Get-ItemPropertyValue -Path 'HKCU:\Software\Policies\Immidio\Flex Profiles\Arguments' -Name 'ProfileArchivePath') + "\Applications\Chrome.zip"
$PathToFlex = "C:\Program Files\Immidio\Flex Profiles"

try {
Start-Process "FlexEngine.Exe" -WorkingDirectory $PathToFlex -ArgumentList " -r $ProfArchPath"
}
catch
{
Write-Warning $Error[0]
}

But when i want to import Mozilla Firefox profile with a space before .zip, with this script:

$ProfArchPath = @()
$ProfArchPath = (Get-ItemPropertyValue -Path 'HKCU:\Software\Policies\Immidio\Flex Profiles\Arguments' -Name 'ProfileArchivePath') + "\Applications\Mozilla Firefox.zip"
$PathToFlex = "C:\Program Files\Immidio\Flex Profiles"

try {
Start-Process "FlexEngine.Exe" -WorkingDirectory $PathToFlex -ArgumentList " -r $ProfArchPath"
}
catch
{
Write-Warning $Error[0]
}

i get this error message:

Error

Any idea?

Stian,
Welcome to the forum. :wave:t4:

Use single quotes for $ProfArchPath in your -ArgumentList.

Well, i tried this:

Start-Process "FlexEngine.Exe" -WorkingDirectory $PathToFlex -ArgumentList ' -r '$ProfArchPath' '

Outcome was:
WARNING: A positional parameter cannot be found that accepts argument ‘\server\profile$\username\Archives\Applications\Mozilla Firefox.zip’

I recommended to use single quotes only for the path - not for the -ArgumentList itself and especially not for both. :wink: