0

So I've got this super simple script that uses msiexec to install a MSI, but it doesn't take the one of the flags. This is the the format that installs correctly:

msiexec /qn /i "C:\temp\DNS_Agent_Setup.msi" NKEY="1234567890"

This script block fails because the NKEY likely isn't accepted:

param(
  [String]$SITESECRETKEY
  )
$key = "NKEY=`"$SITESECRETKEY`""
$msiPath = "C:\temp\DNS_Agent_Setup.msi"

Invoke-WebRequest -Uri "https://download.dnsfilter.com/User_Agent/Windows/DNS_Agent_Setup.msi" -OutFile $msiPath
msiexec /qn /i $msiPath $key

Am I just dense?

When I replaced $key with NKEY="123457890" in: msiexec /qn /i $msiPath $key

It works

2
  • Please format your post properly. Commented Dec 11, 2024 at 19:04
  • "NKEY=`"$SITESECRETKEY`"" only works as an msiexec.exe argument in Windows PowerShell by default; if you're running PowerShell (Core) 7.3 or above, you'll need to (temporarily) set ` $PSNativeCommandArgumentPassing = 'Legacy'` - see this answer for details. Commented Dec 11, 2024 at 19:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.