new
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,33 @@
|
|||||||
|
# Detection Script – RustDesk mit korrektem Server konfiguriert
|
||||||
|
# Gibt nichts aus + ExitCode 0 = installiert/konform
|
||||||
|
# Gibt Text aus + ExitCode 1 = nicht installiert / falsch konfiguriert
|
||||||
|
|
||||||
|
$ExpectedServer = "rd.wende.it"
|
||||||
|
$ExpectedKey = "aPiGBXPfnyXtDCN8tiut2IziZeadbmocOdJEduzKtoQ"
|
||||||
|
|
||||||
|
# Prüfe Exe
|
||||||
|
$RustDeskExe = "$env:ProgramFiles\RustDesk\rustdesk.exe"
|
||||||
|
if (-not (Test-Path $RustDeskExe)) {
|
||||||
|
Write-Output "RustDesk nicht installiert."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Prüfe Config (ProgramData)
|
||||||
|
$TomlPath = "$env:ProgramData\RustDesk\RustDesk2.toml"
|
||||||
|
if (-not (Test-Path $TomlPath)) {
|
||||||
|
Write-Output "Konfigurationsdatei fehlt."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$content = Get-Content $TomlPath -Raw
|
||||||
|
if ($content -notmatch [regex]::Escape($ExpectedServer)) {
|
||||||
|
Write-Output "Falscher Server konfiguriert."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
if ($content -notmatch [regex]::Escape($ExpectedKey)) {
|
||||||
|
Write-Output "Falscher Public Key konfiguriert."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Alles OK
|
||||||
|
exit 0
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
#Requires -RunAsAdministrator
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
RustDesk Silent Install + Konfiguration für privaten Server
|
||||||
|
.DESCRIPTION
|
||||||
|
Installiert RustDesk und konfiguriert automatisch den privaten
|
||||||
|
HBBS/HBBR-Server (rd.wende.it) inkl. Public Key.
|
||||||
|
Geeignet für Intune (Win32) und SCCM Deployment.
|
||||||
|
.NOTES
|
||||||
|
Server: rd.wende.it
|
||||||
|
Public Key: aPiGBXPfnyXtDCN8tiut2IziZeadbmocOdJEduzKtoQ
|
||||||
|
#>
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# Konfiguration
|
||||||
|
# ============================================================
|
||||||
|
$RustDeskVersion = "1.3.8"
|
||||||
|
$InstallerUrl = "https://github.com/rustdesk/rustdesk/releases/download/$RustDeskVersion/rustdesk-$RustDeskVersion-x86_64.exe"
|
||||||
|
$InstallerPath = "$env:TEMP\rustdesk-setup.exe"
|
||||||
|
$InstallDir = "$env:ProgramFiles\RustDesk"
|
||||||
|
$ConfigDir = "$env:ProgramData\RustDesk"
|
||||||
|
|
||||||
|
$HbbsServer = "rd.wende.it"
|
||||||
|
$HbbrServer = "rd.wende.it" # HBBR läuft auf demselben Host
|
||||||
|
$PublicKey = "aPiGBXPfnyXtDCN8tiut2IziZeadbmocOdJEduzKtoQ"
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# Logging
|
||||||
|
# ============================================================
|
||||||
|
$LogFile = "$env:ProgramData\Microsoft\IntuneManagementExtension\Logs\Install-RustDesk.log"
|
||||||
|
function Write-Log {
|
||||||
|
param([string]$Message)
|
||||||
|
$ts = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||||
|
"$ts $Message" | Tee-Object -FilePath $LogFile -Append | Write-Output
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Log "=== RustDesk Deployment gestartet ==="
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# 1. Download
|
||||||
|
# ============================================================
|
||||||
|
if (-not (Test-Path $InstallerPath)) {
|
||||||
|
Write-Log "Download: $InstallerUrl"
|
||||||
|
try {
|
||||||
|
Invoke-WebRequest -Uri $InstallerUrl -OutFile $InstallerPath -UseBasicParsing
|
||||||
|
Write-Log "Download abgeschlossen."
|
||||||
|
} catch {
|
||||||
|
Write-Log "FEHLER beim Download: $_"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Log "Installer bereits vorhanden, überspringe Download."
|
||||||
|
}
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# 2. Silent Install
|
||||||
|
# ============================================================
|
||||||
|
Write-Log "Starte Silent-Installation..."
|
||||||
|
$proc = Start-Process -FilePath $InstallerPath -ArgumentList "--silent-install" -Wait -PassThru
|
||||||
|
if ($proc.ExitCode -notin @(0, 3010)) {
|
||||||
|
Write-Log "FEHLER: Installer ExitCode $($proc.ExitCode)"
|
||||||
|
exit $proc.ExitCode
|
||||||
|
}
|
||||||
|
Write-Log "Installation abgeschlossen (ExitCode: $($proc.ExitCode))."
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# 3. Warte auf rustdesk.exe
|
||||||
|
# ============================================================
|
||||||
|
$RustDeskExe = "$InstallDir\rustdesk.exe"
|
||||||
|
$timeout = 30
|
||||||
|
$elapsed = 0
|
||||||
|
while (-not (Test-Path $RustDeskExe) -and $elapsed -lt $timeout) {
|
||||||
|
Start-Sleep -Seconds 2
|
||||||
|
$elapsed += 2
|
||||||
|
}
|
||||||
|
if (-not (Test-Path $RustDeskExe)) {
|
||||||
|
Write-Log "FEHLER: rustdesk.exe nicht gefunden nach $timeout Sekunden."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# 4. RustDesk kurz starten (erzeugt Config-Dateien)
|
||||||
|
# ============================================================
|
||||||
|
Write-Log "Starte RustDesk einmalig zur Config-Initialisierung..."
|
||||||
|
Start-Process -FilePath $RustDeskExe -ArgumentList "--service" -NoNewWindow
|
||||||
|
Start-Sleep -Seconds 5
|
||||||
|
Stop-Process -Name "rustdesk" -Force -ErrorAction SilentlyContinue
|
||||||
|
Start-Sleep -Seconds 2
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# 5. Konfiguration schreiben (RustDesk2.toml)
|
||||||
|
# ============================================================
|
||||||
|
if (-not (Test-Path $ConfigDir)) {
|
||||||
|
New-Item -ItemType Directory -Path $ConfigDir -Force | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
$RustDesk2Toml = @"
|
||||||
|
rendezvous_server = '$HbbsServer'
|
||||||
|
nat_type = 1
|
||||||
|
serial = 0
|
||||||
|
|
||||||
|
[options]
|
||||||
|
custom-rendezvous-server = '$HbbsServer'
|
||||||
|
relay-server = '$HbbrServer'
|
||||||
|
api-server = 'https://$HbbsServer'
|
||||||
|
key = '$PublicKey'
|
||||||
|
direct-server = 'Y'
|
||||||
|
direct-access-port = '21118'
|
||||||
|
"@
|
||||||
|
|
||||||
|
$TomlPath = "$ConfigDir\RustDesk2.toml"
|
||||||
|
$RustDesk2Toml | Set-Content -Path $TomlPath -Encoding UTF8 -Force
|
||||||
|
Write-Log "Konfiguration geschrieben: $TomlPath"
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# 6. Konfiguration auch im User-Profil hinterlegen (All Users)
|
||||||
|
# ============================================================
|
||||||
|
# RustDesk liest je nach Version aus AppData – sicherstellen dass
|
||||||
|
# alle bestehenden Profile ebenfalls die Config erhalten
|
||||||
|
$UserProfiles = Get-ChildItem "C:\Users" -Directory | Where-Object {
|
||||||
|
$_.Name -notmatch '^(Public|Default.*|All Users)$'
|
||||||
|
}
|
||||||
|
foreach ($profile in $UserProfiles) {
|
||||||
|
$userConfigDir = "$($profile.FullName)\AppData\Roaming\RustDesk\config"
|
||||||
|
if (-not (Test-Path $userConfigDir)) {
|
||||||
|
New-Item -ItemType Directory -Path $userConfigDir -Force | Out-Null
|
||||||
|
}
|
||||||
|
$RustDesk2Toml | Set-Content -Path "$userConfigDir\RustDesk2.toml" -Encoding UTF8 -Force
|
||||||
|
Write-Log "User-Config geschrieben: $userConfigDir"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Default-Profil (für neue User)
|
||||||
|
$defaultConfigDir = "C:\Users\Default\AppData\Roaming\RustDesk\config"
|
||||||
|
if (-not (Test-Path $defaultConfigDir)) {
|
||||||
|
New-Item -ItemType Directory -Path $defaultConfigDir -Force | Out-Null
|
||||||
|
}
|
||||||
|
$RustDesk2Toml | Set-Content -Path "$defaultConfigDir\RustDesk2.toml" -Encoding UTF8 -Force
|
||||||
|
Write-Log "Default-Profil Config geschrieben."
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# 7. RustDesk-Dienst starten
|
||||||
|
# ============================================================
|
||||||
|
Write-Log "Starte RustDesk-Dienst..."
|
||||||
|
Start-Process -FilePath $RustDeskExe -ArgumentList "--install-service" -Wait -NoNewWindow -ErrorAction SilentlyContinue
|
||||||
|
Start-Sleep -Seconds 3
|
||||||
|
$svc = Get-Service -Name "RustDesk" -ErrorAction SilentlyContinue
|
||||||
|
if ($svc) {
|
||||||
|
Start-Service -Name "RustDesk" -ErrorAction SilentlyContinue
|
||||||
|
Write-Log "RustDesk-Dienst Status: $($svc.Status)"
|
||||||
|
} else {
|
||||||
|
Write-Log "WARNUNG: RustDesk-Dienst nicht gefunden, starte als Prozess."
|
||||||
|
Start-Process -FilePath $RustDeskExe -NoNewWindow
|
||||||
|
}
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# Aufräumen
|
||||||
|
# ============================================================
|
||||||
|
Remove-Item -Path $InstallerPath -Force -ErrorAction SilentlyContinue
|
||||||
|
Write-Log "=== RustDesk Deployment abgeschlossen ==="
|
||||||
|
exit 0
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
#Requires -RunAsAdministrator
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
RustDesk Silent Uninstall
|
||||||
|
#>
|
||||||
|
|
||||||
|
$LogFile = "$env:ProgramData\Microsoft\IntuneManagementExtension\Logs\Uninstall-RustDesk.log"
|
||||||
|
function Write-Log {
|
||||||
|
param([string]$Message)
|
||||||
|
$ts = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||||
|
"$ts $Message" | Tee-Object -FilePath $LogFile -Append | Write-Output
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Log "=== RustDesk Uninstall gestartet ==="
|
||||||
|
|
||||||
|
# Dienst stoppen
|
||||||
|
Stop-Service -Name "RustDesk" -Force -ErrorAction SilentlyContinue
|
||||||
|
Stop-Process -Name "rustdesk" -Force -ErrorAction SilentlyContinue
|
||||||
|
Start-Sleep -Seconds 2
|
||||||
|
|
||||||
|
# Über rustdesk.exe deinstallieren
|
||||||
|
$RustDeskExe = "$env:ProgramFiles\RustDesk\rustdesk.exe"
|
||||||
|
if (Test-Path $RustDeskExe) {
|
||||||
|
Write-Log "Starte Uninstall via rustdesk.exe..."
|
||||||
|
Start-Process -FilePath $RustDeskExe -ArgumentList "--uninstall-service" -Wait -NoNewWindow -ErrorAction SilentlyContinue
|
||||||
|
Start-Process -FilePath $RustDeskExe -ArgumentList "--silent-install", "/uninstall" -Wait -NoNewWindow -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
|
||||||
|
# Über Registry (Uninstall-String)
|
||||||
|
$uninstallKeys = @(
|
||||||
|
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall",
|
||||||
|
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
|
||||||
|
)
|
||||||
|
foreach ($key in $uninstallKeys) {
|
||||||
|
Get-ChildItem $key -ErrorAction SilentlyContinue | ForEach-Object {
|
||||||
|
$displayName = (Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue).DisplayName
|
||||||
|
if ($displayName -like "*RustDesk*") {
|
||||||
|
$uninstallStr = (Get-ItemProperty $_.PSPath).UninstallString
|
||||||
|
Write-Log "Uninstall-String gefunden: $uninstallStr"
|
||||||
|
Start-Process -FilePath "cmd.exe" -ArgumentList "/c $uninstallStr /S" -Wait -NoNewWindow -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Reste entfernen
|
||||||
|
$paths = @(
|
||||||
|
"$env:ProgramFiles\RustDesk",
|
||||||
|
"$env:ProgramData\RustDesk"
|
||||||
|
)
|
||||||
|
foreach ($p in $paths) {
|
||||||
|
if (Test-Path $p) {
|
||||||
|
Remove-Item -Path $p -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
Write-Log "Entfernt: $p"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Log "=== RustDesk Uninstall abgeschlossen ==="
|
||||||
|
exit 0
|
||||||
Reference in New Issue
Block a user