Intune appends «/qn ALLUSERS=1»

Andy BrunnerTechnik

Are you trying to run a Powershell script as an Intune install command and you have the string .msi in it and realized that your command fails, because Intune automatically modifies it? Here is the thing. As soon as Intune finds .msi in your install command, it appends /qn ALLUSERS=1 on its own. Even if they had good intentions to implement this, when we want to run a powershell script, they break our command.

Here is our install command in the Intune Administration GUI.

And here you see what is executed on the client.

If you have named arguments in your Powershell script, the command will break. Powershell will throw an error because it does not know any parameter «/qn» or «ALLUSERS=1».

Here is an example. If you have the following Install command, you will get an error.

powershell -executionpolicy bypass -file .\installer.ps1 -myMSI "https://domain.com/myMsiPackage.msi"

The trick is to use unnamed arguments in your script. In the following example, we removed -myMSI.

powershell -executionpolicy bypass -file .\installer.ps1 "https://domain.com/myMsiPackage.msi"

Now, at the top of your script, don’t catch the parameters with a param() block. Catch them with the $args array. The installer.ps1 would start with the following line.

$myMSI = $args[0]
# $myMSI will contain -> https://domain.com/myMsiPackage.msi

# the rest can be ignored
# $args[1] will contain -> /qn
# $args[2] will contain -> ALLUSERS=1

Very easy if you know how.