1

I am writing a script to go through our fleet of Windows machines, search for a couple of applications, and uninstall them if found.

To achieve this, I am using two commands

Get-Package
Uninstall-Package

The way in which I am doing this remotely, is using the below

Invoke-Command -ComputerName $ComputerName -ScriptBlock {Get-Package | Where {($_.Name -Like "Wazuh*") -or ($_.Name -like "Invinsec*")} | Uninstall-Package}

Whilst this runs in a foreach loop, for every machine it runs against where it finds a package, it prompts me with the following message

Would you like PackageManagement to automatically download and install 'nuget' now?

I do not understand why it asking me to install nuget, when I am attempting to uninstall a package.

Is there any way to suppress this prompt? I cannot find any reference to this message relating to Uninstall-Package, so cannot determine how to get rid of it.

Eds1989
  • 11
  • 4

1 Answers1

0

I managed to suppress the warning, by specifying msi as the ProviderName

Uninstall-Package -ProviderName msi -Name $_.Name
Eds1989
  • 11
  • 4