Select Page

Required Files: None


This script checks to see if your screenconnect service is there and running. If the service does not exist, it will download it from YOUR url and then quietly install.


 

Import-Module $env:SyncroModule
 
# Replace this with YOUR screenconnect client service name
$serviceName = 'ScreenConnect Client (ffaabb112233)'
 
# URL for ScreenConnect exe download
$url = 'http://www.yoursite.com/files/sc.msi'
 
# URL for your screenconnect instance, you can customize the port or leave it off
$scdomain = "http://yourhost.com:8080"
 
# Your syncro subdomain
$subdomain = "yoursHere"
 
# Your email (for the ticket submission)
$yourEmail = "[email protected]"
 
If (Get-Service $serviceName -ErrorAction SilentlyContinue) {
   If ((Get-Service $serviceName).Status -eq 'Running') {
       # do nothing
   } Else {
       #$ticket = Create-Syncro-Ticket -Subdomain $subdomain -Subject "ScreenConnect needs started on $env:computername" -IssueType "Automated" -Status "New"
       Write-Host "$serviceName found, but it is not running for some reason."
       write-host "starting $servicename"
       start-service $serviceName
       #$startAt = (Get-Date).AddMinutes(-30).toString("o")
       #Create-Syncro-Ticket-TimerEntry -Subdomain $subdomain -TicketIdOrNumber $ticket.ticket.id -StartTime $startAt -DurationMinutes 5 -Notes "Automated system cleaned up the disk space." -UserIdOrEmail $yourEmail
 
   }
} Else {
   #$ticket = Create-Syncro-Ticket -Subdomain $subdomain -Subject "ScreenConnect needs installed on $env:computername" -IssueType "Automated" -Status "New"
 
   Write-Host "$serviceName not found - need to install"
   (new-object System.Net.WebClient).DownloadFile($url,'C:\windows\temp\sc.msi')
   msiexec.exe /i c:\windows\temp\sc.msi /quiet
   #$startAt = (Get-Date).AddMinutes(-30).toString("o")
   #Create-Syncro-Ticket-TimerEntry -Subdomain $subdomain -TicketIdOrNumber $ticket.ticket.id -StartTime $startAt -DurationMinutes 5 -Notes "Automated system cleaned up the disk space." -UserIdOrEmail $yourEmail
 
}
 
 
$Keys = Get-ChildItem HKLM:\System\ControlSet001\Services
$Guid = "Null";
$Items = $Keys | Foreach-Object {Get-ItemProperty $_.PsPath }
 
    ForEach ($Item in $Items)
    {
        if ($item.PSChildName -like "*ScreenConnect Client*")
    {
    $SubKeyName = $Item.PSChildName
    $Guid = (Get-ItemProperty "HKLM:\SYSTEM\ControlSet001\Services\$SubKeyName").ImagePath
    }
}
 
$GuidParser1 = $Guid -split "&s="
$GuidParser2 = $GuidParser1[1] -split "&k="
$Guid = $GuidParser2[0]
$ScreenConnectUrl = "https://$scdomain/Host#Access/All%20Machines//$Guid/Join"
 
Write-Host ScreenConnect URL Is: $ScreenConnectUrl
 
Set-Asset-Field -Subdomain $subdomain -Name "Screenconnect" -Value $ScreenConnectUrl