# Script to install MeshCentral Agent. # Technolog Networks - 2024-08-20 # iRaven Start-Transcript -Path "c:\irnh\Install-MeshCentral-Agent.log" -Append $ADCompOU = ([adsisearcher]"(&(objectClass=computer)(sAMAccountName=$env:computername$))").FindOne().GetDirectoryEntry().distinguishedName Function CheckInstall { if (test-path -path "c:\Program Files\Mesh Agent") { return $true } else { return $false } } if ((CheckInstall) -eq $false) { if ($ADCompOU -like "*Headend*") { # We put this at the top due to our OU structure. (e.g. OU=Headend, OU=Domain Servers/OU=Workstations) Write-Host "Installing Headend Mesh Agent..." \\technolog.net\netlogon\TNGMeshInstaller\meshagent64-Headend.exe -fullinstall } elseif ($ADCompOU -like "*Workstations*") { Write-Host "Installing WKS Mesh Agent..." \\technolog.net\netlogon\TNGMeshInstaller\meshagent64-NH-WKS.exe -fullinstall } elseif ($ADCompOU -like "*Domain Servers*") { Write-Host "Installing Servers Mesh Agent..." \\technolog.net\netlogon\TNGMeshInstaller\meshagent64-NH-Servers.exe -fullinstall } else { Write-Error -Message "No OU was defined or computer is not joined to domain." } } Stop-Transcript