How to pass msi ArgumentList with $ScriptDir with spaces in powershell? How to pass msi ArgumentList with $ScriptDir with spaces in powershell? powershell powershell

How to pass msi ArgumentList with $ScriptDir with spaces in powershell?


If you were to call msiexec.exe (or most other commands) from the command line with a path with spaces in it, you'd need to wrap that path in quotes.

Unfortunately, your path by the time it's being passed through doesn't actually have them (despite supplying them in your hash table.)

To do this, provide some escaped quotes (""):

$MSIArguments = @(    "/i"    """$ScriptDir\PBIDesktop.msi"""    "/qn" #   "/norestart"     "ACCEPT_EULA=1")

This has the practical end result of: for paths, wrap them in three quote marks.