How to use Powershell to delete a WMI entry

Welcome Forums General PowerShell Q&A How to use Powershell to delete a WMI entry

  • This topic has 3 replies, 3 voices, and was last updated 1 month ago by
    js
    Participant
    .
Viewing 3 reply threads
  • Author
    Posts
    • #194597
      Participant
      Topics: 1
      Replies: 0
      Points: 11
      Rank: Member

      Is it possible to use Powershell to delete an object from WMI.

      Specifically one of two AntivirusProducts under root\securitycenter2
      The AntivirusProduct has a uniqe Guid

      Any examples would be appreciated

    • #194753
      js
      Participant
      Topics: 27
      Replies: 739
      Points: 2,013
      Helping Hand
      Rank: Community Hero
      get-wmiobject win32_printer | where name -eq printername | remove-wmiobject
      
    • #194993
      Participant
      Topics: 2
      Replies: 16
      Points: 69
      Helping Hand
      Rank: Member

      Although I think this is a bad idea, and I did NOT test this, it should work. Just change the InstanceID

      Get-WmiObject -ClassName 'AntivirusProduct' -NameSpace 'root\securityCenter2' | Where-Object {$_.instanceGuid -Match '{XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}'} | Remove-WmiObject

    • #194996
      js
      Participant
      Topics: 27
      Replies: 739
      Points: 2,013
      Helping Hand
      Rank: Community Hero

      If it's an msi provider, uninstall package should work.

      get-package *antivirus* | uninstall-package
      
Viewing 3 reply threads
  • You must be logged in to reply to this topic.