I have found many posts regarding the uninstall of office prior to the install of 0ffice 365. This one has been a great help:
https://social.technet.microsoft.com/Forums/en-US/fd735611-95bf-46f6-8add-2229a52e3e93/i-can-not-uninstall-office-2013-from-command-line?forum=officeitpro
How ever I have not been able to find an answer to the underlying issue that is causing the error: "Failed to enforce app. Error 0x87d00213"
This error occurs when the sccm application "Times out". In many cases the application runs properly but still produces the 0x87d00213 error. This seems to be occurring because the application is NOT producing an exit code.
Without an exit code the sccm dependencies are not checked and the application is not "enforced"
I am using the command line from the link above to remove office 2013 before installing office 365 and from the appenforce.log I get the following:
Prepared command line: "C:\WINDOWS\ccmcache\mx\setup.exe" /uninstall ProPlus /config Uninstall.xmlAppEnforce12/19/2018 10:59:43 AM6184 (0x1828)
Executing Command line: "C:\WINDOWS\ccmcache\mx\setup.exe" /uninstall ProPlus /config Uninstall.xml with system contextAppEnforce12/19/2018 10:59:43 AM6184 (0x1828)
Working directory C:\WINDOWS\ccmcache\mxAppEnforce12/19/2018 10:59:43 AM6184 (0x1828)
Post install behavior is BasedOnExitCodeAppEnforce12/19/2018 10:59:43 AM6184 (0x1828)
Waiting for process 9816 to finish. Timeout = 120 minutes.AppEnforce12/19/2018 10:59:43 AM6184 (0x1828)
2 hours later
Exceeded timeout of 120 minutes while waiting for process 9816 to finish.AppEnforce12/19/2018 12:59:43 PM6184 (0x1828)
WaitForRunningProcess failed. Error 0x87d00213.
AppEnforce
12/19/2018 12:59:43 PM
6184 (0x1828)
CMsiHandler::CompleteEnforcement failed with 0x87d00213
AppEnforce
12/19/2018 12:59:43 PM
6184 (0x1828)
CAppProvider::CompleteEnforcement failed with error 0x87d00213
AppEnforce
12/19/2018 12:59:43 PM
6184 (0x1828)
++++++ Failed to enforce app. Error 0x87d00213. ++++++
AppEnforce
12/19/2018 12:59:43 PM
6184 (0x1828)
The error is generated because no exit code is returned.
The install of o365 works great and an exit code is returned
<![LOG[ Prepared command line: "C:\WINDOWS\ccmcache\lx\setup.exe" /configure config-Office365only-x64.xml]LOG]!><time="13:11:46.212+360" date="12-19-2018" component="AppEnforce" context=""
type="1" thread="5540" file="appcontext.cpp:338">
<![LOG[ Executing Command line: "C:\WINDOWS\ccmcache\lx\setup.exe" /configure config-Office365only-x64.xml with system context]LOG]!><time="13:11:46.212+360" date="12-19-2018" component="AppEnforce"
context="" type="1" thread="5540" file="appexcnlib.cpp:205">
<![LOG[ Working directory C:\WINDOWS\ccmcache\lx]LOG]!><time="13:11:46.213+360" date="12-19-2018" component="AppEnforce" context="" type="1" thread="5540" file="appexcnlib.cpp:219">
<![LOG[ Post install behavior is BasedOnExitCode]LOG]!><time="13:11:46.296+360" date="12-19-2018" component="AppEnforce" context="" type="1" thread="5540" file="appcommon.cpp:1094">
<![LOG[ Waiting for process 11580 to finish. Timeout = 120 minutes.]LOG]!><time="13:11:46.306+360" date="12-19-2018" component="AppEnforce" context="" type="1" thread="5540"
file="appexcnlib.cpp:2015">
<![LOG[ Process 11580 terminated with exitcode: 0]LOG]!><time="13:15:13.187+360" date="12-19-2018" component="AppEnforce" context=""
type="1" thread="5540" file="appexcnlib.cpp:2024">
<![LOG[ Looking for exit code 0 in exit codes table...]LOG]!><time="13:15:13.188+360" date="12-19-2018" component="AppEnforce" context="" type="1" thread="5540" file="appexcnlib.cpp:508">
<![LOG[ Matched exit code 0 to a Success entry in exit codes table.]LOG]!><time="13:15:13.194+360" date="12-19-2018" component="AppEnforce" context="" type="1" thread="5540"
file="appexcnlib.cpp:587">
<![LOG[ Performing detection of app deployment type Scripted office 365(ScopeId_D5A9CE73-D60E-4DB1-BFFA-E60C501B3FEB/DeploymentType_b15dd095-d717-4777-88da-81df8dd48dfb, revision 6) for system.]LOG]!><time="13:15:13.221+360"
date="12-19-2018" component="AppEnforce" context="" type="1" thread="5540" file="appprovider.cpp:2148">
<![LOG[+++ Discovered application [AppDT Id: ScopeId_D5A9CE73-D60E-4DB1-BFFA-E60C501B3FEB/DeploymentType_b15dd095-d717-4777-88da-81df8dd48dfb, Revision: 6]]LOG]!><time="13:15:13.245+360" date="12-19-2018" component="AppEnforce"
context="" type="1" thread="5540" file="localapphandler.cpp:287">
<![LOG[++++++ App enforcement completed (207 seconds) for App DT "Scripted office 365" [ScopeId_D5A9CE73-D60E-4DB1-BFFA-E60C501B3FEB/DeploymentType_b15dd095-d717-4777-88da-81df8dd48dfb], Revision: 6, User SID: ] ++++++]LOG]!><time="13:15:13.264+360"
date="12-19-2018" component="AppEnforce" context="" type="1" thread="5540" file="appprovider.cpp:2450">
Since this produces the exit code SCCM checks it against the dependencies and then enforces the application. I realize this is a lot but the basic question remains why is the uninstall not sending an exit code?
Thanks
Mike