bulk uninstall software

Welcome Forums General PowerShell Q&A bulk uninstall software

This topic contains 4 replies, has 3 voices, and was last updated by

 
Participant
3 months, 3 weeks ago.

  • Author
    Posts
  • #105293

    Participant
    Points: 0
    Rank: Member

    hello guys ...
    im trying to uninstall a software " oracle virtualbox " so i made a simple powershell script

    Invoke-Command -ScriptBlock {Get-CimInstance -ClassName Win32_Product -ComputerName (Get-Content D:\Powershell\Computernames.txt) -Filter "name like '%virtualbox%'" | Remove-CimInstance -Verbose}

    ... but for some reason it only works if im logged on to the remote pc via Remote desktop ... though the -verbose shows that its performing some actions

    VERBOSE: Perform operation 'Delete CimInstance' with following parameters, ''namespaceName' = root/cimv2,'instance' = Win32_Product: Oracle VM VirtualBox 5.1.
    22 (IdentifyingNumber = "{8D5E4D4D-5E0C-4448-B018-5DDEF1E208D9}", Name = "Oracle VM VirtualBox 5.1.22", Version = "5.1.22")'.
    VERBOSE: Performing the operation "Remove-CimInstance" on target "Win32_Product: Oracle VM VirtualBox 5.1.22 (IdentifyingNumber = "{8D5E4D4D-5E0C-4448-B018-5D
    DEF1E208D9}", Name = "Oracle VM VirtualBox 5.1.22", Version = "5.1.22")".
    VERBOSE: Perform operation 'Delete CimInstance' with following parameters, ''namespaceName' = root/cimv2,'instance' = Win32_Product: Oracle VM VirtualBox 5.1.
    22 (IdentifyingNumber = "{8D5E4D4D-5E0C-4448-B018-5DDEF1E208D9}", Name = "Oracle VM VirtualBox 5.1.22", Version = "5.1.22")'.
    VERBOSE: Operation 'Delete CimInstance' complete.
    VERBOSE: Operation 'Delete CimInstance' complete.
    VERBOSE: Operation 'Delete CimInstance' complete.

    any help please ?

  • #105322

    Keymaster
    Points: 1,625
    Helping HandTeam Member
    Rank: Community Hero

    This is not a Pester question. Moving to the correct forum.

  • #105325

    Keymaster
    Points: 1,625
    Helping HandTeam Member
    Rank: Community Hero

    Many installers are badly made and won't work without a full user profile; PowerShell Remoting does not create a full user profile. Short of repackaging the software into a better installer, there's not much you can do about that.

  • #105365

    Participant
    Points: 213
    Helping Hand
    Rank: Participant

    How was the software installed?

    Why not copy your script to a shared location, and set it as a RunOnce option on the users systems?
    Why not remotely create a scheduled task, which runs once at user logon, to remove the software?
    If the software was install via a tool like SCCM then use SCCM to remove it?
    If the software was installed using GPO, then it can be removed with GPO?

    How about changing this up a bit.

    Get-Content 'D:\Powershell\Computernames.txt' %{
    "Processing actions on $_"
    Invoke-Command -ComputerName $_ -ScriptBlock {Get-CimInstance -ClassName Win32_Product -Filter "name like '%virtualbox%'"}
    }
    

    Also, Win32_Product can be very slow and has other issues...

    'gregramsey.net/2012/02/20/win32_product-is-evil'

    'powershell.org/forums/topic/alternatives-to-win32_product'

    … so, depending on your scenario, it's best to use an alternative.

    • #105439

      Participant
      Points: 0
      Rank: Member

      the software was installed one by one pc ... i will try your suggestions thanks

The topic ‘bulk uninstall software’ is closed to new replies.