+5
Under Review

Sync clients/hosts grouping from Active Directory groups(OU)

josh fredrickson 7 years ago updated by Kilo 4 years ago 2

We are in the Trial for Screenconnect and like what we see but it seems to be missing a very useful feature we currently have in our remote control solution.


When a new client becomes visible in Screenconnect we would like it find that object in Active Directory and create a Group in Screenconnect with the name of the AD OU. We would then like to have the client put into that group.


For example lets say we have computers in Spain, Costa Rica, and United States. These computers are organized in Active Directory with three different OU's named with the country names.


When a computer that is in the Spain AD OU has the Screenconnect client installed and checks in for the first time the server would create a Spain Group in Screenconnect and move the client into that group.


That way all object/client management is done in Active Directory.


Hopefully what I said makes sense :)

I second that request!

Here is a basic script that you can use with GPO to accomplish this for now.

clear

#Find the full Distinguished name of the computer without using Get-AdComputer

$filter = "(&(objectCategory=computer)(objectClass=computer)(cn=$env:COMPUTERNAME))"

$disName = ([adsisearcher]$filter).FindOne().Properties.distinguishedname

#Split Full Distinguished name into usable fields for URL

$ouArray = $disName.Split(",")

#Remove Unwatned contents of the string

foreach ($ou in $ouArray) {

$ouArray[$ouArray.IndexOf($ou)] = $ou.SubString(3)

}

#Build the download link for ScreenConnect

#Enter the Base URL for your ScreenConnect Instance (This is required and can be retrieved by building an MSI installer from your ScreenConnect Console with no custom properties defined and then removing "&c=&c=&c=&c=&c=&c=&c=" from the end of the provided URL

$downloadBase = "Your Base URL Here"

#Modify this string depending on your specific OU structure and how you want it to map to your fields

$finalURL = $downloadBase + $ouArray[5] + "&c="+ $ouArray[4] + "&c="+ $ouArray[3] + "&c="+ $ouArray[2] + "&c="+ $ouArray[1] + "&c=&c=&c="

#Create clean Location for the file download

if (-Not (Test-Path C:\SC-Temp)) {

New-Item -Path "c:\" -Name "SC-Temp" -ItemType "directory" -Force | Out-Null

}else {

Remove-Item 'C:\SC-Temp' -Recurse -Force

New-Item -Path "c:\" -Name "SC-Temp" -ItemType "directory" -Force

}

#Download the MSI for installation

$downloadPath = "C:\SC-Temp\ScreenConnect.msi"

Invoke-WebRequest -Uri $finalURL -OutFile $downloadPath

#Install ScreenConnect Client Silently

Start-Process msiexec.exe -ArgumentList '/I',$downloadPath, '/qn' -Wait

#Clean up remaining Files

Remove-Item 'C:\SC-Temp' -Recurse -Force

Let me know if you have any questions