DEV Community

Cover image for Intune appends «/qn ALLUSERS=1»
Andreas Brunner
Andreas Brunner

Posted on • Originally published at cloudxs.ch

Intune appends «/qn ALLUSERS=1»

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.

Install command in GUI

And here you see what is executed on the client.

Install command in log file

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"
Enter fullscreen mode Exit fullscreen mode

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"
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Very easy if you know how.

Top comments (0)