Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6934585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:58:47+00:00 2026-05-27T11:58:47+00:00

(Get-WmiObject -Class Win32_Product -ComputerName $PCNumber -ErrorAction SilentlyContinue | Where-Object { $_.Name -match $softwareName }).Uninstall()

  • 0
(Get-WmiObject -Class Win32_Product -ComputerName $PCNumber -ErrorAction SilentlyContinue | Where-Object { $_.Name -match "$softwareName" }).Uninstall() | Out-Null

I have following code which works perfectly. The only problem is that I wont to know if the software has been removed or not.This doesn’t tells me but the code below does.

This way works for me.

$software = Get-WmiObject -Class Win32_Product -ComputerName $PCNumber -ErrorAction SilentlyContinue | Where-Object { $_.Name -match "$softwareName" }

$soft = $software.Uninstall();
$n = $software.ReturnValue;

if ( $n -eq 0 ){
SOFTWARE HAS BEEN REMOVED.
}

my question is that how do i tell if the software has been removed or not.
using this code.

(Get-WmiObject -Class Win32_Product -ComputerName $PCNumber -ErrorAction SilentlyContinue | Where-Object { $_.Name -match "$softwareName" }).Uninstall() | Out-Null
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:58:47+00:00Added an answer on May 27, 2026 at 11:58 am

    You have to check the ReturnValue property. When you pipe to Out-Null you are suppressing the output of the operation and there’s no way to tell what happened, unless you issue a second call to find if it returns the software in question.

    I recommend using the Filter parameter (instead of using Where-Object) to query the software on the server. To be safe you should also pipe the results to the Foreach-Object cmdlet, you never know how many software objects you get back due to the match operation (and you call the Uninstall method as if the result is one object only):

    Get-WmiObject -Class Win32_Product -ComputerName $PCNumber -Filter "Name LIKE '%$softwareName%'" | Foreach-Object { 
    
         Write-Host "Uninstalling: $($_.Name)"
    
         $rv = $_.Uninstall().ReturnValue 
    
         if($rv -eq 0)
         {
            "$($_.Name) uninstalled successfully"
         }     # Changed this round bracket to a squigly one to prperly close the scriptblock for "if"
         else
         {
            "There was an error ($rv) uninstalling $($_.Name)"
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i start out by querying an exchange server 2003 with: POSH>get-wmiobject -class Exchange_mailbox -namespace
I've got some troubles with Get-WmiObject and usage of this object. In case, I'm
I'm trying to run a simple Get-WmiObject call in PowerShell. Get-WmiObject -computerName $srv -namespace
I am running a test on servers with the following line: Get-WmiObject Win32_Service -ComputerName
I get an Access is Denied error message when I use the strong name
I would like to use Get-WmiObject Win32_NetworkAdapterConfiguration to return the ip address of a
Caveat: Without spiking the cpu while a Get-WmiObject call parses the whole event log
get current array position pointer while doing foreach $object->result_array() Hi, consider this, a case.
In PowerShell you can use the Get-WmiObject cmdlet to grab WMI classes. I have
Get object 's array value in php $obj = new Basecamp($bcUrl, $bcApikey, 'X', 'simplexml');

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.