We've been trialing DC for about two weeks now and decided to scale larger for a proof of concept. We deployed the agent via Intune, and it worked great for the most part. However, we had about ~75 machines that something happened during Agent installation and it was installed, but not communicating with the server. After working closely with support for a bit, it was determined the agent would need to be reinstalled manually on these devices.
Great! I said, how can I do that remotely?
Well... you can't, at least according to ME Support as of yesterday. Which is a major bummer, but I never let a good challenge get in the way. So I've come up with a simple Powershell script for install/uninstall/reinstall of the Desktop Central agent that can be deployed via Intune (or modified for other platforms) that I'd like to share here, in hopes of two things:
1. That I hopefully save some poor future admin from having to go through all this again, and
2. That someone from the ME team sees this and forwards to support/engineering for verification, and maybe tweaked/posted as an official resource
Before I go any further, please note this script is provided AS IS, and neither ME (since it's their forum) nor I are responsible for any issues that may arise from using this in your environment.
Having gotten that out of the way, see below for the script:
#Declares the switches as parameters
#This will run if script is called with -Install switch
cmd.exe /c 'setup.bat'
#This will run if script is called with -Uninstall switch
Start-Process msiexec.exe -ArgumentList $UninstallArgs
#This will run if script is called with -Reinstall switch
$Removal= Start-Process msiexec.exe -ArgumentList $UninstallArgs -PassThru
cmd.exe /c 'setup.bat'
#This is optional, it generates a text file to use for Intune detection rules (can't use product code or registry since it will already exist prior to reinstall)
In order to use this for Intune, save the above as Powershell script. Then copy the script and the following items all into one folder (these can be found by going to Agent > Agent Installation > Other Methods > Command Prompt > Download):
Now, use the IntuneWinAppUtil to wrap this all up into a .intunewin package, using DesktopCentralAgent.ps1 as the source file.
From here, go to Intune and create a new Win32 app, uploading the intunewin we just created. If you're doing this for the purpose of re-installing Desktop Central Agent, then for the Install command you'll use:
- Powershell -ExeuctionPolicy Bypass -File DesktopCentralAgent.ps1 -Reinstall
For the uninstall command, we can use:
- Powershell -ExecutionPolicy Bypass -File DesktopCentralAgent.ps1 -Uninstall
For detection methods, manually configure it to look for the file C:\Windows\Temp\DCAgentReinstalled.txt
Then assign away!
P.S., this script can be used to install/uninstall/reinstall the agent. To call a specific function, run
- DesktopCentralAgent.ps1 -Install
- DesktopCentralAgent.ps1 -Uninstall
- DesktopCentralAgent.ps1 -Reinstall