I want to create a function to remove a program through powershell. What I can't seem to figure out is how exactly to do that.
My code:
function RemoveProgram {
$app = Get-CimInstance -Class Win32_Product | Where-Object {
$_.Name -match $args
}
$app.Uninstall()
}
However, when I run this, I get
Method invocation failed because [Microsoft.Management.Infrastructure.CimInstance] does not contain a method named 'Uninstall'.
Does anyone have some tips on how to make it better?
Invoke-CimMethodOR switch back to usingGet-WmiObjectsince it still has live connections to the data.