Forum Discussion

AB21805's avatar
AB21805
Bronze Contributor
Oct 14, 2021

Removing the incorrect office apps on devices

Hi all,

 

I have a strange thing with all our intune devices, we have 2 offices installed: 

 

 

I need to remove the top one (Microsoft 365 - en-us) as it contains ONENOTE which we dont want on devices but within intune there is only one OFFICE we deploy which doesnt contain ONENOTE 

 

When I remove Microsoft 365 - en-us manually onenote is removed

 

So does any one know how we remove the one that contains onenote? 

 

Thanks in advance

  • Rudy_Ooms_MVP's avatar
    Rudy_Ooms_MVP
    Oct 16, 2021

    AB21805 

    Hi, just changed some lines it ... nothing much but again.. you will need to change the displayname to exactly the app you whish to remove 🙂 

     

    $OfficeUninstallStrings = ((Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*") |
    Where {$_.DisplayName -like "Microsoft 365 Apps for enterprise - en-us"} |
    Select UninstallString).UninstallString

    ForEach ($UninstallString in $OfficeUninstallStrings) {
    $UninstallEXE = ($UninstallString -split '"')[1]
    $UninstallArg = ($UninstallString -split '"')[2] + " DisplayLevel=False"
    Start-Process -FilePath $UninstallEXE -ArgumentList $UninstallArg -Wait
    }

     

    Looks like its working at my end

     

     

     

  • I guess you need to test it first ... but take a look at the uninstall reg key I am mentioning to get the proper displayname 🙂


    $OfficeUninstallStrings = ((Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*") `
    + (Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*") |
    Where {$_.DisplayName -like "Microsoft 365 - en-us"} |
    Select UninstallString).UninstallString

    ForEach ($UninstallString in $OfficeUninstallStrings) {
    $UninstallEXE = ($UninstallString -split '"')[1]
    $UninstallArg = ($UninstallString -split '"')[2] + " DisplayLevel=False"
    Start-Process -FilePath $UninstallEXE -ArgumentList $UninstallArg -Wait
    }
    • AB21805's avatar
      AB21805
      Bronze Contributor
      Hi Rudy,

      thanks for this but no luck is there meant to be a space between " and DisplayLevel=False ?
  • I will take a look what happens when I run it on a test device this afternoon, i will keep you posted!
    • Rudy_Ooms_MVP's avatar
      Rudy_Ooms_MVP
      MVP

      AB21805 

      Hi, just changed some lines it ... nothing much but again.. you will need to change the displayname to exactly the app you whish to remove 🙂 

       

      $OfficeUninstallStrings = ((Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*") |
      Where {$_.DisplayName -like "Microsoft 365 Apps for enterprise - en-us"} |
      Select UninstallString).UninstallString

      ForEach ($UninstallString in $OfficeUninstallStrings) {
      $UninstallEXE = ($UninstallString -split '"')[1]
      $UninstallArg = ($UninstallString -split '"')[2] + " DisplayLevel=False"
      Start-Process -FilePath $UninstallEXE -ArgumentList $UninstallArg -Wait
      }

       

      Looks like its working at my end

       

       

       

      • AB21805's avatar
        AB21805
        Bronze Contributor

        Hi Rudy_Ooms_MVP 

         

        I am unable to remove office 

         

        Here is the script (which I have tried to run manually on the device rather than intune first)

         

        $OfficeUninstallStrings = ((Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*") |
        Where {$_.DisplayName -like "Office 16 Click-to-Run Licensing Component"} |
        Select UninstallString).UninstallString

        ForEach ($UninstallString in $OfficeUninstallStrings) {
        $UninstallEXE = ($UninstallString -split '"')[1]
        $UninstallArg = ($UninstallString -split '"')[2] + " DisplayLevel=False"
        Start-Process -FilePath $UninstallEXE -ArgumentList $UninstallArg -Wait
        }

         

         

        Any idea where I am going wrong? 

Resources