locked
Remove Application from client through SCCM RRS feed

  • Question

  • We have a package in SCCM and need to use the package to delete client from the application. Can we also use a powershell script in sccm and delete the application?

    • Edited by Avyayah Friday, February 21, 2020 11:01 PM
    Friday, February 21, 2020 9:49 PM

All replies

  • Friday, February 21, 2020 11:08 PM
  • Hi,

    Thanks for posting in TechNet.

    Yes, we can use PowerShell script to remove application from the clients in Configuration Manager. For more information, please refer to:

    Using PowerShell to Uninstall Applications with Hardware Inventory
    Uninstall Software En Masse
    Uninstall an Application in Software Center with PowerShell
    Mass Uninstall SCCM PowerShell Script by Publisher

    Hope my answer could help you. Thanks for your time.

    Best regards,
    Simon

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Saturday, February 22, 2020 1:28 PM
  • Hi Simon,

    Thank you for sending the delayed description of the removal of application using PowerShell script but if this is for specific computer and I would like to include the computer name. Is that possible?

    ##Get list of all products installed
    $InstalledProducts = Get-WmiObject -Namespace 'root\cimv2\sms' -Class SMS_InstalledSoftware
    ## Check the matches
    $InstalledProducts | where { $_.ARPDisplayName -imatch 'eSigner' }
    ## Add specific product to variable
    $eSigner = $InstalledProducts | where { ($_.ARPDisplayName -eq 'eSigner 4.2') -and ($_.ProductVersion

    Monday, February 24, 2020 3:26 PM
  • It is powershell you can do anything but why do you want to deploy this script to a collection only to remove it from one computer?

    For that matter, why not use the Script feature within CMCB to do this? Are you on CMCB or just CM12? 


    Garth Jones

    Blog: https://www.enhansoft.com/blog Old Blog: https://sccmug.ca/

    Twitter: @GarthMJ Book: System Center Configuration Manager Reporting Unleashed

    Monday, February 24, 2020 4:11 PM
  • I would like to test it on computer only before removing from all client PC's. We are on System Center 2012 R2 Configuration Manager SP1
    Monday, February 24, 2020 5:00 PM
  • So create a collection for that single computer and deploy the script to it. 

    Garth Jones

    Blog: https://www.enhansoft.com/blog Old Blog: https://sccmug.ca/

    Twitter: @GarthMJ Book: System Center Configuration Manager Reporting Unleashed

    Monday, February 24, 2020 5:28 PM
  • ###SCCMOG##
    ##Mass Uninstall the Application by unique ID - Publisher
    ### To Deploy use program string: powershell.exe -Executionpolicy Bypass -File MassUninstallMSI.ps1
    ### SCCM_OG 16/07/2016

    ##Enter unique Identifier - Remember to change line  from Publisher if not using that as unique.
    $Unique = "Gemalto"
    $DetectKey = "HKLM:\SOFTWARE\RSDELL\SCRIPTS\MassRemMSI\$Unique"
    function set-detectionKeys()
    {
        New-Item -Path HKLM:\SOFTWARE\ -Name RSDELL –Force
        New-Item -Path HKLM:\SOFTWARE\RSDELL -Name SCRIPTS –Force
        New-Item -Path HKLM:\SOFTWARE\RSDELL\SCRIPTS -Name MassRemMSI –Force
        New-Item -Path HKLM:\SOFTWARE\RSDELL\SCRIPTS\MassRemMSI -Name $Unique –Force

    }

    ##Get all Applications in SMS namespace
    $InstalledProducts = Get-WmiObject -Namespace 'c\Program Files\7-Zip' -Class SMS_InstalledSoftware

    #Grab all of those applications with Publisher of....
    $AppArray = $InstalledProducts | where { $_.Publisher -like $Unique }

    If ($AppArray.Length -eq 0)
    {
        set-detectionKeys
        Set-ItemProperty -Path $DetectKey -Name Array -Value 'NoneFound' -Force
        Write-Host "No applcations Found Exiting with code 0"
        Exit 0
    }

    Elseif ($AppArray.Length -gt 0)

    {
        set-detectionKeys
        #Uninstall the applications found
        for ($i=0; $i -lt $AppArray.Length; $i++)
        {
            &quot;<code>$AppArray[$i]=&quot; + $AppArray[$i].ARPDisplayName
            &quot;</code>$AppArray[$i]=&quot; + $AppArray[$i].Localpackage
            $packagename = $AppArray[$i].ARPDisplayName
            $packagename = $packagename -replace '\s',''
            $log = &quot;/l*v $env:windir\temp\uninstall_$packagename.log&quot;
            $arguments = &quot;/x &quot; + $AppArray[$i].Localpackage + &quot; /qn /norestart $log&quot;
            $Passthru = Start-Process 'msiexec.exe' -ArgumentList $arguments -Wait -NoNewWindow -PassThru
            $Exitcode = [string]$Passthru.ExitCode
            Set-ItemProperty -Path $DetectKey -Name $packagename -Value &quot;ExitCode: $ExitCode&quot; -Force
        }

        Write-Host &quot;Applcations Found and removed. Exiting with code 3010 for reboot.&quot;
        Exit 3010
    }
    Else
    {
        set-detectionKeys
        Set-ItemProperty -Path $DetectKey -Name Else -Value 'NoneFound' -Force
        Write-Host &quot;No applcations Found Exiting with code 0&quot;
        Exit 0
    }

    ##The End :)
    #######################################################

    Planning to remove the 7-zip from client computer. Is this the only change in the script that I should make?

    $InstalledProducts = Get-WmiObject -Namespace 'c\Program Files\7-Zip' -Class SMS_InstalledSoftware

                 
    Monday, February 24, 2020 11:01 PM