SOLVED

Removing the incorrect office apps on devices

Bronze Contributor

Hi all,

 

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

 

office.PNG

 

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

8 Replies
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
}
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!
best response confirmed by AB21805 (Bronze Contributor)
Solution

@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

 

Rudy_Ooms_0-1634368090933.png

 

Rudy_Ooms_1-1634368090940.png

 

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
}

 

new.PNG

 

Any idea where I am going wrong? 

I guess that one is not the one you need :)

Hi @Rudy_Ooms_MVP 

 

I have tried this again which worked when doing it locally: 

 

 $OfficeUninstallStrings = ((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

} 

 

 

But when trying through intune it succeeds but office isnt removed! Any ideas where i am going wrong? 

 

Screenshot 2022-04-07 at 10.09.34 AM.png

 

Please help!

 

Hi @Rudy_Ooms_MVP 

 

Its because I didnt run as 64 bit! Worked perfectly, thank you!

1 best response

Accepted Solutions
best response confirmed by AB21805 (Bronze Contributor)
Solution

@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

 

Rudy_Ooms_0-1634368090933.png

 

Rudy_Ooms_1-1634368090940.png

 

View solution in original post