Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Trying to remotely uninstall an app

$
0
0

Hello,

I'm fairly new to PS and I've been working on a script to uninstall an application from a remote machine.

this is what i have so far:

$computers = "COMPA"

foreach ($computers in $computers){

    invoke-command -computerName $computers -scriptblock {
    $app = (Get-WmiObject -Class Win32_Product | Where-Object {$_.IdentifyingNumber -match "CDD4495B-0424-42F0-8D89-70D47E21BD69"})
    $app.uninstall()
    }
}

however i get the following error when i run the script:

You cannot call a method on a null-valued expression.
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

any feedback would be great.


Viewing all articles
Browse latest Browse all 15028

Trending Articles