Spaces Truncated in $app* Variables

I’ve noticed that if I reference the $appName or $appVendor variables within the Deploy-Application.ps1 script, that if those variables have spaces, they spaces get removed. For example, trying to deploy Adobe’s After Effects. I set $appName to ‘After Effects’, but when I use "Execute-MSI -Path “$appName.msi” in the script file, the script runs “msiexec.exe /i AfterEffects.msi”, which breaks the deployment if the msi is named “After Effects.msi”.

Is this is known issue or limitation within Powershell? Obviously, a easy workaround is to remove spaces from file/folder names, but just wondering if there is a fix for this.

Thanks!

Have you tried using double quotes around the variable?

[string]$appName = “After Effects”

Looks like you may not want to use double quotes… They are removing the spaces on purpose:

Sanitize the application details, as they can cause issues in the script

[char[]]$invalidFileNameChars = [IO.Path]::GetInvalidFileNameChars()
[string]$appVendor = $appVendor -replace “[$invalidFileNameChars]”,’’ -replace ’ ‘,’’
[string]$appName = $appName -replace “[$invalidFileNameChars]”,’’ -replace ’ ‘,’’
[string]$appVersion = $appVersion -replace “[$invalidFileNameChars]”,’’ -replace ’ ‘,’’
[string]$appArch = $appArch -replace “[$invalidFileNameChars]”,’’ -replace ’ ‘,’’
[string]$appLang = $appLang -replace “[$invalidFileNameChars]”,’’ -replace ’ ‘,’’
[string]$appRevision = $appRevision -replace “[$invalidFileNameChars]”,’’ -replace ’ ‘,’’