Wichtigste Erkenntnisse
- Automatisierte Effizienz: Automatisiert die URL-Erzeugung in ConnectWise ScreenConnect und verbessert die betriebliche Effizienz.
- Flexibilität der Parameter: Unterstützt dynamische Konfigurationen durch Parameter wie Domain, Sitzungsgruppe und Instanz-ID.
- Administratorrechte: Erfordert Administratorrechte für die Änderung von benutzerdefinierten Feldern und den Zugriff auf die Registrierung.
- Überprüfung der Installation: Überprüft die ScreenConnect-Installation anhand der Systemregistrierung und stellt eine gezielte Skriptausführung sicher.
- Direkte URL-Erstellung: Generiert direkte Start-URLs für jede ScreenConnect-Instanz und minimiert so die manuelle Eingabe.
- Integrationspotenzial: Das Skript lässt sich einfach in größere IT-Automatisierungsworkflows integrieren und ist daher skalierbar.
- Sicherheitserwägungen: Es besteht die Notwendigkeit einer sicheren Skriptverwendung, um unbefugten Zugriff zu verhindern.
- Integration in NinjaOne: Zeigt das Potenzial der Integration und Effizienzsteigerung mit NinjaOne für die Fernverwaltung von Systemen.
Im dynamischen Bereich der Informationstechnologie ist die Fähigkeit, Remote-Systeme effizient zu verwalten und zu unterstützen, von größter Bedeutung. Ein wichtiger Akteur in diesem Bereich ist ConnectWise ScreenConnect, eine robuste Lösung für Fern-Support, -Zugriff und -Meetings. Die Automatisierung der Bereitstellung und Integration durch PowerShell-Skripte erhöht die Effizienz und Zuverlässigkeit, eine Notwendigkeit für IT-Expert:innen und Managed Service Provider (MSPs).
Kontext
Das Skript im Fokus wurde entwickelt, um den Abruf von Start-URLs in ConnectWise ScreenConnect zu automatisieren und sie in einem benutzerdefinierten Feld zu speichern. Diese Automatisierung ist essenziell für IT-Umgebungen, in denen ein schneller, nahtloser Fernzugriff auf mehrere Rechner eine tägliche Anforderung ist. Die Fähigkeit des Skripts, bestimmte Instanzen von ScreenConnect zu identifizieren und direkte Verbindungs-URLs zu generieren, spart wertvolle Zeit und reduziert manuelle Fehler, was es zu einem unverzichtbaren Tool für IT-Support und Management macht.
Das Skript zur Automatisierung von Start-URLs in ConnectWise ScreenConnect
<# .SYNOPSIS Get ConnectWise ScreenConnect Launch URL and save to custom field (defaults to screenconnectUrl). Requires the domain used for ScreenConnect and a Session Group the machine is a part of to successfully build URL. .DESCRIPTION Get ConnectWise ScreenConnect Launch URL and save to custom field (defaults to screenconnectUrl). Requires the domain used for ScreenConnect and a Session Group the machine is a part of to successfully build URL. .EXAMPLE -ScreenConnectDomain "replace.me" -InstanceID "1111111111" Building Launch URL(s)... Launch URL(s) Created Instance : 1111111111 LaunchURL : https://replace.me/Host#Access/All%20Machines//555555-555-555-5555-55555/Join SessionId : 555555-555-555-5555-55555 PARAMETER: -ScreenConnectDomain "ExampleInput" The domain used for your Connectwise ScreenConnect Instance. PARAMETER: -SessionGroup "ExampleInput" The Session Group in which the machine would normally be found. Defaults to "All Machines". PARAMETER: -InstanceID "ExampleInput" The Instance ID for your instance of ScreenConnect. Used to differentiate between multiple installed ScreenConnect Instances. To get the instance id you can see it in the program's name in Control Panel e.g. ScreenConnect Client (yourinstanceidishere) or in ScreenConnect itself (Admin > Advanced > Server Information > Instance Identifier Fingerprint). PARAMETER: -CustomField "ReplaceWithAnyMultilineCustomField" The custom field you would like to write the results to. Defaults to screenconnectUrl .OUTPUTS None .NOTES Minimum OS Architecture Supported: Windows 7+, Server 2008+ Release Notes: Initial Release By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https://www.ninjaone.com/terms-of-use. Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA). #> [CmdletBinding()] param ( [Parameter()] [String]$ScreenConnectDomain, [Parameter()] [String]$SessionGroup = "All Machines", [Parameter()] [String]$InstanceID, [Parameter()] [String]$CustomField = "screenconnectUrl" ) begin { if ($env:screenconnectDomain -and $env:screenconnectDomain -notlike "null") { $ScreenConnectDomain = $env:screenconnectDomain } if ($env:sessionGroup -and $env:sessionGroup -notlike "null") { $SessionGroup = $env:sessionGroup } if ($env:instanceId -and $env:instanceId -notlike "null") { $InstanceID = $env:instanceId } if ($env:customFieldName -and $env:customFieldName -notlike "null") { $CustomField = $env:customFieldName } # Warn end-user if we're not provided an instance id if (-not ($InstanceID)) { Write-Warning "Without the instance id we will be unable to tell which ScreenConnect instance is yours if multiple are installed resulting in the wrong URL being displayed." Write-Warning "To get the instance id you can see it in the programs name in Control Panel ex. ScreenConnect Client (yourinstanceidishere) or in Control itself (Admin > Advanced > Server Information > Instance Identifier Fingerprint)" } # These two are actually necessary to build the URL if (-not ($ScreenConnectDomain) -or -not ($SessionGroup)) { Write-Error "Unable to build URL without the domain or Session Group." exit 1 } # Test for elevation function Test-IsElevated { $id = [System.Security.Principal.WindowsIdentity]::GetCurrent() $p = New-Object System.Security.Principal.WindowsPrincipal($id) $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator) } # Checks the two Uninstall registry keys to see if the app is installed. Needs the name as it would appear in Control Panel. function Find-UninstallKey { [CmdletBinding()] param ( [Parameter(ValueFromPipeline = $True)] [String]$DisplayName, [Parameter()] [Switch]$UninstallString ) process { $UninstallList = New-Object System.Collections.Generic.List[Object] $Result = Get-ChildItem HKLM:SoftwareWow6432NodeMicrosoftWindowsCurrentVersionUninstall* | Get-ItemProperty | Where-Object { $_.DisplayName -like "*$DisplayName*" } if ($Result) { $UninstallList.Add($Result) } $Result = Get-ChildItem HKLM:SoftwareMicrosoftWindowsCurrentVersionUninstall* | Get-ItemProperty | Where-Object { $_.DisplayName -like "*$DisplayName*" } if ($Result) { $UninstallList.Add($Result) } # Programs don't always have an uninstall string listed here so to account for that I made this optional. if ($UninstallString) { $UninstallList | Select-Object -ExpandProperty UninstallString -ErrorAction SilentlyContinue } else { $UninstallList } } } # Define the name of the software we are searching for and look for it in both the 64 bit and 32 bit registry nodes. if (-not $InstanceID) { $SoftwareName = "ScreenConnect Client" }else { $SoftwareName = "ScreenConnect Client ($InstanceID)" } $ControlInstallation = Find-UninstallKey -DisplayName $SoftwareName # If its not installed lets error out. if (-not ($ControlInstallation)) { Write-Error "Connectwise ScreenConnect is not installed!" exit 1 } # Elevation is required to write to custom fields. if (-not (Test-IsElevated)) { Write-Error -Message "Access Denied. Please run with Administrator privileges." exit 1 } } process { # The Image Path Registry Key contains the unique session id needed to generate the URL Write-Host "Building Launch URL(s)..." $ControlInstances = $ControlInstallation.DisplayName | ForEach-Object { $ImagePath = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServices$_" | Select-Object -Property ImagePath -ExpandProperty ImagePath $Id = ($ImagePath -split '&' | Where-Object { $_ -match 's=(.*-){4}' }) -replace "s=" $Instance = ($_ -replace "ScreenConnect Client (" -replace ")").trim() New-Object psobject -Property @{ Instance = $Instance LaunchURL = [URI]::EscapeUriString("https://$ScreenConnectDomain/Host#Access/$SessionGroup//$Id/Join") SessionId = $Id } } # Create a Table/List of our results Write-Host "Launch URL(s) Created" $ControlInstances | Format-List -Property Instance, LaunchURL, SessionId | Out-String | Write-Host # PowerShell 2.0 does not support ninjarmm-cli if ($PSVersionTable.PSVersion.Major -gt 2) { if ($ControlInstances.LaunchURL.Count -gt 1) { Ninja-Property-Set -Name $CustomField -Value ($ControlInstances | Format-List -Property Instance, LaunchURL | Out-String) } else { Ninja-Property-Set -Name $CustomField -Value ($ControlInstances.LaunchURL | Out-String) } } else { Write-Host "ninjarmm-cli does not support PowerShell 1 & 2. Refer to https://ninjarmm.zendesk.com/hc/en-us/articles/4405408656013 ." } } end { }
Greifen Sie auf über 300 Skripte im NinjaOne Dojo zu.
Detailansicht
- Initialisierung der Parameter: Das Skript beginnt mit der Definition von Parametern wie ScreenConnectDomain, SessionGroup, InstanceID und CustomField. Diese Parameter sind wichtig, um die spezifische ScreenConnect-Instanz und die Maschinengruppe darin zu identifizieren.
- Überprüfung der Umgebungsvariablen: Es prüft, ob Umgebungsvariablen vorhanden sind, und verwendet sie, wenn diese gesetzt sind. Diese Flexibilität ermöglicht eine dynamische Anpassung an unterschiedliche Systemkonfigurationen.
- Prüfungen vor der Ausführung: Das Skript sorgt dafür, dass die erforderlichen Parameter angegeben werden, und prüft, ob Administratorrechte vorhanden sind, da die Änderung benutzerdefinierter Felder erhöhte Berechtigungen erfordert.
- Überprüfung der Software-Installation: Das Skript durchsucht die Systemregistrierung, um zu überprüfen, ob ScreenConnect installiert ist, und identifiziert die richtige Instanz anhand der angegebenen Instanz-ID.
- URL-Generierung: Dies ist die Kernfunktionalität des Skripts, bei der die Start-URL für ScreenConnect unter Verwendung der Domain, der Sitzungsgruppe und einer eindeutigen Sitzungs-ID aus der Systemregistrierung erstellt wird.
- Ausgabeformatierung: Die generierten URLs werden in einer lesbaren Liste formatiert, die Benutzer:innen klare, umsetzbare Informationen liefert.
Potenzielle Anwendungsfälle
Stellen Sie sich vor, ein IT-Experte verwaltet eine Vielfalt von Rechnern an mehreren Standorten. Er muss schnell zur Fehlerbehebung eine Verbindung zu jeder Maschine herstellen können. Mit diesem Skript kann er direkte ScreenConnect-URLs für jeden Rechner generieren und in einem benutzerdefinierten Feld speichern, was einen sofortigen Fernzugriff ohne manuelle URL-Erstellung ermöglicht.
Vergleiche
Bei der Erstellung von ScreenConnect-URLs ist es üblich, die Sitzungs-ID jedes Rechners manuell zu identifizieren und die URL zu erstellen. Dieses Skript automatisiert den Prozess und reduziert damit den Zeitaufwand und die Fehleranfälligkeit erheblich. Im Vergleich zu GUI-basierten Methoden bietet das Skript Skalierbarkeit und Integrationsmöglichkeiten mit anderen Automatisierungsworkflows.
FAQs
- Wie stellt dieses Skript sicher, dass es die richtige ScreenConnect-Instanz anvisiert?
Das Skript verwendet den Parameter ‚InstanceID‘, um die richtige ScreenConnect-Instanz zu identifizieren. - Kann dieses Skript in größere Automatisierungsabläufe integriert werden?
Ja, dank der PowerShell-Kompatibilität lässt es sich leicht in breitere IT-Automatisierungssysteme integrieren. - Sind für die Ausführung dieses Skripts Administratorrechte erforderlich?
Ja, da es das Schreiben in benutzerdefinierte Felder und den Zugriff auf Systemregistrierungen beinhaltet.
Folgen
Die Automatisierung der URL-Generierung steigert die betriebliche Effizienz, birgt aber auch ein Risiko, wenn sie missbraucht wird. Wenn ein unbefugter Zugriff auf das Skript erfolgt, kann dies zu Sicherheitsverletzungen führen. Daher ist die Sicherung des Skripts und der Umgebung, in der es verwendet wird, essenziell.
Empfehlungen
- Sichern Sie die Umgebung: Führen Sie das Skript in einer sicheren, kontrollierten Umgebung aus.
- Regelmäßige Updates: Halten Sie ConnectWise ScreenConnect und PowerShell auf dem neuesten Stand.
- Zugriffskontrolle: Beschränken Sie den Zugriff auf das Skript auf autorisiertes Personal.
Abschließende Überlegungen
Die Einbindung solcher Skripte in die NinjaOne-Plattform kann die Aufgaben der Fernverwaltung rationalisieren und so eine kohärentere und effizientere Verwaltung ermöglichen. Die Fähigkeit von NinjaOne, sich mit Tools wie ConnectWise ScreenConnect zu integrieren, ist ein Beweis für die Nützlichkeit des Systems in der sich ständig weiterentwickelnden IT-Welt. Darüber hinaus wird NinjaOne durch die Leistungsfähigkeit der Automatisierung ergänzt.