0

I am trying to uninstall a software package, eset, in powershell by passing the product identifying number using a variable. The script works when using the productID, but not when using a variable holding the product ID.

$product = Get-WmiObject -Class Win32_Product | Where-Object Name -EQ "ESET Endpoint Antivirus" Write-Host "Product found:$product"

$productID = $product.IdentifyingNumber Write-Host "Product Identifying Number:$productID"

The following code does not work: Start-Process MSIEXEC '/qn /x "$productID" PASSWORD="password" REBOOT="ReallySuppress"'

The following code will work: Start-Process MSIEXEC '/qn /x "{915B4D63-9489-4550-88E8-384CC134A747}" PASSWORD="password" REBOOT="ReallySuppress"'

Error: This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package.

Any help appreciated.

Thanks!

Tried using a variable and tried using the real value. Expected both ways to work, only using the real value without a variable in place worked.

mklement0
  • 382,024
  • 64
  • 607
  • 775
  • Please [format your post properly](https://stackoverflow.com/help/formatting). – mklement0 Dec 28 '22 at 21:03
  • In short: In PowerShell, only `"..."` strings (double-quoted aka _expandable strings_) perform string interpolation (expansion of variable values and expressions), not `'...'` strings (single-quoted aka _verbatim strings_). With `"..."` quoting, if the string value itself contains `"` chars., escape them as `\`"` or `""`, or use a double-quoted _here-string_. See the conceptual [about_Quoting_Rules](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Quoting_Rules) help topics. – mklement0 Dec 28 '22 at 21:04
  • `uninstall-package 'ESET Endpoint Antivirus'` – js2010 Dec 29 '22 at 01:04

0 Answers0