Teams Rooms - Reinstall Win Device Admin Agent Service

Copper Contributor

Hello,

We are very new to Teams Rooms, trying to deploy our first actually. We have a TAPMSTSMLLEN with Logitech Tap/Meetup and a Lenovo Thinksmart CORE compute Teams Rooms device.

We are still predeployment. We had an issue with the unit on the bench where it started booting to a screen saying that we needed another app to open a link type and could not continue. I chased down the reset process that runs a script then starts the Reset this PC process, wherein you need to erase all content and settings and rebuild the PC. This worked although the problem came back. We found a better, easier answer to the issue and believe that problem is now fixed. After fixing the problem I noted that this Teams Rooms device is not updating its details in the Teams Admin Centre (TAC), where it previously was. I tracked this down to it relying on a Win Device Admin Agent service, which is NOT present on this machine following the reset.

I ran the offline update script on the machine for 4.12.138.0 which simply told me I was up to date and no changes were made.

Is there a way to get this service back, preferably without rebuilding again? Are there logs that could help me, bearing in mind I can't get them from the admin centre. If rebuilding again, do users familiar with Team Rooms think the reset script would work, or would I need to find out how to get a full image build from Lenovo?

Thanks for any info.

4 Replies

I have rerun the device reset process. This time it has installed the service and the device is reporting in the TAC. Will see if it continues to do so.

@matthewpage 

Here is a script to fix the agent

 

$AARegistryPath = "HKLM:\SOFTWARE\Microsoft\PPI\SkypeSettings\INSTALL_AA"
$registryKey = "EnableAAInstall"
$SRSUser = "Skype"
$SRSPackage = "Microsoft.SkypeRoomSystem"
$AgentBinaryName = "WinAgentSvc.exe"
$ServiceName = "WinDeviceAdminAgent"
$ServiceDisplayName = "Win Device Admin Agent"
$ServiceDescription = "Teams Admin Agent for Microsoft Teams Room"

function Join-Paths2 {
$path = $args[0]
$args[1..$args.Count] | ForEach-Object { $path = Join-Path $path $_ }
$path
}

function Get-IsAdminAgentInstallationEnabled {
$IsEnableAAInstallSet = $true;
if (Test-Path -Path $AARegistryPath) {
$registry = Get-Item -path $AARegistryPath -ErrorAction SilentlyContinue
if ($null -ne $registry) {
try {
$IsEnableAAInstallSet = ([bool]::Parse($registry.GetValue($registryKey, $true)))
}
catch {
}
}
}

return $IsEnableAAInstallSet
}

function Get-SRSInstallPath {
$installPath = ""

$user = $SRSUser
$packageName = $SRSPackage
$package = Get-AppxPackage -User $user -Name $packageName

if ($null -ne $package) {
$installPath = $package.InstallLocation
}

return $installPath
}

function Get-AdminAgentVersionInFolder {
param(
[parameter(Mandatory = $true)]
[string]$FolderPath
)

$version = $null
$serviceFilePath = Join-Path $FolderPath $AgentBinaryName

if (Test-Path -Path $serviceFilePath) {
try {
$version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($serviceFilePath).FileVersion
}
catch {
Write-Error -Message "Cannot find admin agent version in path $FolderPath" -Exception $_.Exception
}
}

return $version
}

function CreateServiceUsingServiceController {
param(
[parameter(Mandatory = $true)]
[string]$ServiceFilePath
)

$processArgs = "create $ServiceName binPath=""\""$ServiceFilePath\"""" start=auto DisplayName=""$ServiceDisplayName"""
$process = [System.Diagnostics.Process]::Start("sc.exe", $processArgs)
$process.WaitForExit();
}

$DefaultAgentInstallPath = Join-Paths2 ${env:SystemDrive} "Program Files" "AdminAgent"

# Must be running as admin
$isElevated = "non-elevated"
if (([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
[Security.Principal.WindowsBuiltInRole] "Administrator")) {
$isElevated = "elevated"
}

if ($isElevated -ne "elevated") {
Write-Output "This script must be run with administrative privileges. Use an elevated command prompt."
exit 1
}

$IsAgentInstallationEnabled = Get-IsAdminAgentInstallationEnabled
if ($IsAgentInstallationEnabled -eq $false) {
Write-Output "Admin Agent installation is disabled in the registry."
Write-Output "Removing registry key: $AARegistryPath"
Remove-Item -Path $AARegistryPath -Recurse
Write-Output "Admin Agent installation is now enabled."
}

Write-Output "Checking if service ""$ServiceDisplayName"" is already installed and running ..."

# If agent is installed, service must be in stopped state
$AgentService = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
if ($null -ne $AgentService -and $AgentService.Status -ne [System.ServiceProcess.ServiceControllerStatus]::Stopped) {
Write-Output "The service ""$AgentService.DisplayName"" must be stopped for repair."
Write-Output "Please stop the service using the Powershell command:"
Write-Output "Stop-Service -Name ""$ServiceName"""

exit 1
}

Write-Output "Service ""$ServiceDisplayName"" is not present"

Write-Output "Checking for package $SRSPackage ..."
$SRSInstallPath = Get-SRSInstallPath
# Check if the agent source path is available and valid
if (($null -eq $SRSInstallPath) -or ($SRSInstallPath.Length -eq 0)) {
Write-Output "Skype Room System is not installed. This app must be installed for this script to proceed. Please install this app and run this script again if the issue persists."
exit 1
}

if (-not (Test-Path -Path $SRSInstallPath)) {
Write-Output "The path ""$SRSInstallPath"" is not valid. This path must exist."
exit 1
}

Write-Output "The package ""$SRSPackage"" is present."

$AgentSourceDirectory = Join-Path $SRSInstallPath "Scripts\\AdminAgent"
if (-not (Test-Path -Path $AgentSourceDirectory)) {
Write-Output "Unable to find the path ""$AgentSourceDirectory"". Cannot proceed with the repair."
exit 1
}

# Check if we have a valid version of admin agent in the source folder
$AgentSourceVersion = Get-AdminAgentVersionInFolder -FolderPath $AgentSourceDirectory
if ($null -eq $AgentSourceVersion) {
Write-Output "Cannot find version information of admin agent in source folder. Cannot proceed with the repair."
exit 1
}

Write-Output "Found Admin Agent version $AgentSourceVersion bundled in the package."

$AgentInstallPath = $DefaultAgentInstallPath

Write-Output "Checking for existing installations at ""$AgentInstallPath""."

# Remove older installations
if (Test-Path -Path $AgentInstallPath) {
Write-Output "Removing existing installation at ""$AgentInstallPath""..."
Remove-Item "$AgentInstallPath\\*.*" -Recurse
Start-Sleep -Seconds 2
Remove-Item $AgentInstallPath -Recurse
Start-Sleep -Seconds 2
}

# Copy admin agent binaries
if (-not (Test-Path -Path $AgentInstallPath)) {
Write-Output "Creating folder ""$AgentInstallPath""."
New-Item -Path $AgentInstallPath -ItemType Directory
}

Write-Output "Copying files for Admin Agent..."
Copy-Item -Path $AgentSourceDirectory\* -Destination $AgentInstallPath -Recurse
Write-Output "Admin Agent files copied."

$AgentService = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue

# Delete existing service registration if present
if ($null -ne $AgentService) {
Write-Output "Removing existing service registration for $ServiceDisplayName"
sc.exe delete $ServiceName
}

$AgentService = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
# Create a new service if required
if ($null -eq $AgentService) {
Write-Output "Registering service $ServiceDisplayName"
$serviceFilePath = Join-Path $AgentInstallPath $AgentBinaryName
CreateServiceUsingServiceController -ServiceFilePath $serviceFilePath
sc.exe failure $ServiceName reset=600 actions=restart/60000/restart/120000/restart/240000
}
else {
Write-Output "W: Service registration not removed"
}

Write-Output "Starting service ""$ServiceName"""
# Start the service
sc.exe start $ServiceName

Write-Output "Repair is complete"

@fabiogross Script Works like a Charm.. Many Thanks!!!

Thanks... did the trick for one of the systems we rebuilt.