Enterprise-grade PowerShell deployment automation for RustDeskPro and custom-branded MSI packages
Take a look at my script and guide for installing RustDesk Server Pro with websockets (WSS), its called RustDeskPro-WSS.
- Overview
- Prerequisites
- Installation
- Configuration Files
- Scripts Documentation
- Deployment Workflows
- Microsoft Intune Integration
- Assignment Configuration Guide
- Logging and Troubleshooting
- Security Best Practices
- Advanced Scenarios
- Common Issues and Solutions
- Technical Details
- Support and Contributing
This repository provides a comprehensive deployment solution for RustDesk, designed specifically for enterprise environments. The scripts handle the complete lifecycle of RustDesk deployment including installation, configuration, device assignment to groups and address books, uninstallation, and compliance verification.
- Complete MSI Lifecycle Management: Automated installation, upgrade, and removal processes
- Device Assignment Automation: Automatic assignment to groups and address books post-installation
- Multi-language Support: Full UTF-8 support for international characters (Nordic, European, Asian)
- Custom Branding Support: Works with rebranded RustDesk MSI packages
- Enterprise Logging: Comprehensive dual-layer logging (script logs + MSI verbose logs)
- Intune Integration: Designed for Microsoft Intune and Configuration Manager deployments
- ARM64 Support: Full support for ARM-based Windows devices
- Flexible Configuration: JSON-based configuration with CLI override capabilities
Component | Type | Purpose |
---|---|---|
install.ps1 | PowerShell Script | Handles MSI installation with parameters and optional device assignment |
uninstall.ps1 | PowerShell Script | Manages clean removal via product code or MSI |
check.ps1 | PowerShell Script | Detection script for compliance and verification |
assign.ps1 | PowerShell Script | Assigns devices to groups and address books via API |
config.json | Configuration File | Default settings for all scripts |
assignment.json | Configuration File | Defines group and address book assignments |
- Operating System: Windows 10/11, Windows Server 2016 or later
- PowerShell: Version 5.1 or later (64-bit recommended)
- Privileges: Administrator rights required
- Network: Access to RustDesk server API endpoints
- RustDesk Server Pro: Required for API token functionality
- Version Requirements:
- Server Pro 1.5.8 or later for address book alias support
- Client 1.4.1 or later for full feature compatibility
- API Token: Must be generated with Read/Write permissions for Devices and Groups
- Log into your RustDesk Server Pro web console
- Navigate to Settings → Tokens
- Click Create to generate a new token
- Set the following permissions:
- Devices: Read/Write
- Groups: Read/Write
- Copy and securely store the generated token
- Use this token in the TOKEN parameter of the scripts
-
Download the Scripts
git clone https://github.com/tommyvange/rustdesk-deployment-scripts.git cd rustdesk-deployment-scripts
-
Place Your MSI File
- Copy your RustDesk MSI installer to the scripts directory
- The script will auto-detect the first .msi file if MSIPATH is not specified
-
Configure Settings (Optional)
- Edit
config.json
for default parameters - Edit
assignment.json
for group and address book assignments
- Edit
-
Run Installation
.\install.ps1 -SILENT "true" -LOGGING "true"
RustDesk-Deployment/
├── install.ps1 # Main installation script
├── uninstall.ps1 # Uninstallation script
├── check.ps1 # Detection/verification script
├── assign.ps1 # Assignment automation script
├── config.json # Configuration defaults
├── assignment.json # Assignment definitions
├── RustDesk.msi # MSI installer (example)
└── README.md # Documentation
The main configuration file that provides default values for all script parameters. Command-line arguments always override these defaults.
NOTE: When deploying with Intune I recommend setting the TOKEN variable directly as a CLI-argument instead of leaving it in the config.
{
"INSTALLFOLDER": "",
"CREATESTARTMENUSHORTCUTS": "true",
"CREATEDESKTOPSHORTCUTS": "false",
"INSTALLPRINTER": "false",
"SILENT": "true",
"MSIPATH": "",
"UPGRADE": "false",
"LOGGING": "true",
"ASSIGN": "false",
"TOKEN": "",
"CUSTOMNAME": "",
"ASSIGNMENTFILE": ""
}
Parameter | Type | Default | Description |
---|---|---|---|
INSTALLFOLDER | String | Empty | Custom installation directory. If empty, uses MSI default |
CREATESTARTMENUSHORTCUTS | Boolean String | Empty | Create Start Menu shortcuts ("true"/"false") |
CREATEDESKTOPSHORTCUTS | Boolean String | Empty | Create Desktop shortcuts ("true"/"false") |
INSTALLPRINTER | Boolean String | Empty | Install RustDesk virtual printer ("true"/"false") |
SILENT | Boolean String | "true" | Run installation silently without user interaction |
MSIPATH | String | Empty | Full path to MSI file. If empty, auto-detects in script directory |
UPGRADE | Boolean String | "false" | Indicates this is an upgrade installation |
LOGGING | Boolean String | "true" | Enable detailed script logging |
ASSIGN | Boolean String | "false" | Run assignment script after successful installation |
TOKEN | String | Empty | API token for RustDesk server (required for assignments) |
CUSTOMNAME | String | Empty | Custom executable name for branded builds |
ASSIGNMENTFILE | String | Empty | Path to custom assignment.json file |
Minimal Silent Installation:
{
"SILENT": "true",
"LOGGING": "true"
}
Full Corporate Deployment:
{
"INSTALLFOLDER": "",
"CREATESTARTMENUSHORTCUTS": "true",
"CREATEDESKTOPSHORTCUTS": "false",
"INSTALLPRINTER": "false",
"SILENT": "true",
"LOGGING": "true",
"ASSIGN": "true",
"TOKEN": "your-api-token-here",
"CUSTOMNAME": "CompanyRemote"
}
Defines the device group and address books to assign after installation. Supports UTF-8 characters for international deployments.
{
"group": "Group Name",
"addressBooks": [
{
"addressBook": "Address Book Name",
"alias": "Optional Display Alias",
"tags": [
{
"tag": "Tag Name"
}
]
}
]
}
- Group: Only one group can be assigned per device (RustDesk limitation)
- Address Books: Multiple address books can be assigned
- Alias: One optional alias per address book (requires Server Pro 1.5.8+)
- Tags: Must belong to a parent address book
- UTF-8 Support: Full support for international characters
Simple Department Assignment:
{
"group": "IT Support",
"addressBooks": []
}
Complex Enterprise Structure:
{
"group": "Europe Region",
"addressBooks": [
{
"addressBook": "Corporate Directory",
"alias": "All Employees",
"tags": [
{
"tag": "Executives"
},
{
"tag": "Managers"
},
{
"tag": "Staff"
}
]
},
{
"addressBook": "IT Infrastructure",
"alias": "Servers & Systems",
"tags": [
{
"tag": "Windows Servers"
},
{
"tag": "Linux Servers"
},
{
"tag": "Network Devices"
}
]
},
{
"addressBook": "Support Queue",
"tags": []
}
]
}
NOTE: If you set the parameters in the config, they are not needed here. NOTE: Direct CLI-parameters have a higher priority than the variables inside the config. NOTE: The check.ps1 script does not use the config, and only accepts parameters set as variables inside the file itself.
The primary installation script that handles MSI deployment with extensive customization options.
Parameter | Required | Type | Description |
---|---|---|---|
INSTALLFOLDER | No | String | Custom installation path |
CREATESTARTMENUSHORTCUTS | No | Boolean String | Enable/disable Start Menu shortcuts |
CREATEDESKTOPSHORTCUTS | No | Boolean String | Enable/disable Desktop shortcuts |
INSTALLPRINTER | No | Boolean String | Install virtual printer driver |
SILENT | No | Boolean String | Silent installation mode |
MSIPATH | No | String | Path to MSI file |
UPGRADE | No | Boolean String | Upgrade mode flag |
LOGGING | No | Boolean String | Enable script logging |
ASSIGN | No | Boolean String | Run assignment after installation |
TOKEN | Conditional | String | API token (required if ASSIGN="true") |
CUSTOMNAME | No | String | Custom executable name |
ASSIGNMENTFILE | No | String | Custom assignment file path |
Basic Installation:
.\install.ps1 -SILENT "true" -LOGGING "true"
Custom Installation Path:
.\install.ps1 `
-INSTALLFOLDER "D:\Programs\RustDesk" `
-SILENT "true" `
-LOGGING "true"
Installation with Assignment:
.\install.ps1 `
-SILENT "true" `
-ASSIGN "true" `
-TOKEN "api_1234567890abcdef" `
-LOGGING "true"
Full Custom Deployment:
.\install.ps1 `
-INSTALLFOLDER "C:\Corporate\RemoteAccess" `
-CREATESTARTMENUSHORTCUTS "true" `
-CREATEDESKTOPSHORTCUTS "false" `
-INSTALLPRINTER "false" `
-SILENT "true" `
-MSIPATH "\\fileserver\software\RustDesk-1.3.9.msi" `
-ASSIGN "true" `
-TOKEN "api_1234567890abcdef" `
-CUSTOMNAME "CompanyRemote" `
-ASSIGNMENTFILE ".\configs\production-assignment.json" `
-LOGGING "true"
Code | Meaning | Description |
---|---|---|
0 | Success | Installation completed successfully |
3010 | Success with Reboot | Installation successful, reboot required |
1603 | Fatal Error | Installation failed |
1619 | Package Error | MSI package could not be opened |
1638 | Version Conflict | Another version already installed |
Handles clean removal of RustDesk installations.
Parameter | Required | Type | Description |
---|---|---|---|
MSIPATH | No | String | MSI path for uninstall (fallback method) |
INSTALLFOLDER | No | String | Original installation directory |
SILENT | No | Boolean String | Silent uninstallation |
LOGGING | No | Boolean String | Enable script logging |
Standard Uninstall:
.\uninstall.ps1 -SILENT "true" -LOGGING "true"
Uninstall with MSI:
.\uninstall.ps1 `
-MSIPATH ".\RustDesk-1.3.9.msi" `
-SILENT "true" `
-LOGGING "true"
Standalone detection script for verification and compliance checking.
$enableLogging = $true # Enable/disable logging
$checkRegistryPath = $true # Check Windows registry
$checkFilePath = $true # Check file system
$expectedVersion = "" # Expected version (empty = any)
$customName = "" # Custom name (empty = "RustDesk")
$expectedInstallPath = "C:\Program Files\%customName%" # Path with placeholder
- Registry Check: Scans uninstall registry keys
- WMI Query: Queries Win32_Product class
- File System: Verifies executable presence and version
# Run detection
.\check.ps1
# Check for specific version
# Edit script: $expectedVersion = "1.3.9"
.\check.ps1
Manages device assignment to groups and address books via RustDesk API.
Parameter | Required | Type | Description |
---|---|---|---|
TOKEN | Yes | String | RustDesk API token |
CUSTOMNAME | No | String | Custom executable name |
INSTALLFOLDER | No | String | Installation directory |
LOGGING | No | Boolean String | Enable logging |
ASSIGNMENTFILE | No | String | Assignment configuration path |
Basic Assignment:
.\assign.ps1 `
-TOKEN "api_1234567890abcdef" `
-LOGGING "true"
Custom Configuration:
.\assign.ps1 `
-TOKEN "api_1234567890abcdef" `
-ASSIGNMENTFILE ".\configs\branch-office.json" `
-CUSTOMNAME "CompanyRemote" `
-LOGGING "true"
- Group Assignment: Assigns single device group (if specified)
- Address Book Creation: Creates/assigns address books
- Alias Application: Sets display aliases for address books
- Tag Assignment: Assigns tags within their parent address books
-
Preparation Phase
- Download scripts and place in deployment directory
- Copy RustDesk MSI to the same directory
- Configure
config.json
with organization defaults - Create
assignment.json
with group/address book structure - Generate API token from RustDesk server
-
Testing Phase
# Test installation on single machine .\install.ps1 -SILENT "true" -LOGGING "true" # Verify installation .\check.ps1 # Test assignment separately .\assign.ps1 -TOKEN "your-token" -LOGGING "true"
-
Production Deployment
# Full deployment with assignment .\install.ps1 ` -SILENT "true" ` -ASSIGN "true" ` -TOKEN "your-token" ` -LOGGING "true"
# Upgrade existing installation
.\install.ps1 `
-UPGRADE "true" `
-SILENT "true" `
-MSIPATH "\\server\share\RustDesk-NewVersion.msi" `
-LOGGING "true"
# Complete removal
.\uninstall.ps1 -SILENT "true" -LOGGING "true"
-
Prepare Package Directory
RustDesk-Intune/ ├── install.ps1 ├── uninstall.ps1 ├── check.ps1 ├── assign.ps1 ├── config.json ├── assignment.json └── RustDesk-1.3.9.msi
-
Create IntuneWin Package
IntuneWinAppUtil.exe ` -c ".\RustDesk-Intune" ` -s "install.ps1" ` -o ".\Output" ` -q
- Name: RustDesk Remote Desktop
- Description: Enterprise remote desktop solution
- Publisher: RustDesk
Without Assignment:
powershell.exe -ExecutionPolicy Bypass -File .\install.ps1
With Assignment:
powershell.exe -ExecutionPolicy Bypass -File .\install.ps1 -TOKEN "your-token"
powershell.exe -ExecutionPolicy Bypass -File .\uninstall.ps1
NOTE: These examples assume you have a valid config.json in the same directory as the scripts.
- Type: Custom script
- Script: Upload
check.ps1
- Run as: System
- Enforce signature check: No
- Run in 64-bit: Yes
Code | Type | Action |
---|---|---|
0 | Success | Continue |
3010 | Soft Reboot | Reboot device |
1641 | Hard Reboot | Force reboot |
1603 | Retry | Retry installation |
Target the Intune app to appropriate Azure AD groups:
- Device groups for computer-based targeting
- User groups for user-based targeting
Device
├── Group (single)
└── Address Books (multiple)
├── Alias (optional)
└── Tags (multiple)
{
"group": "Department or Location Name"
}
Note: Only one group per device is supported by RustDesk.
{
"addressBooks": [
{
"addressBook": "Primary Directory",
"alias": "Display Name"
}
]
}
{
"addressBooks": [
{
"addressBook": "IT Assets",
"alias": "All IT Equipment",
"tags": [
{"tag": "Servers"},
{"tag": "Workstations"},
{"tag": "Network Devices"}
]
}
]
}
{
"group": "Main Office",
"addressBooks": [
{
"addressBook": "All Computers",
"alias": "Company PCs",
"tags": [
{"tag": "Office"},
{"tag": "Remote"}
]
}
]
}
{
"group": "North America",
"addressBooks": [
{
"addressBook": "Finance Department",
"alias": "Finance Team",
"tags": [
{"tag": "Accounting"},
{"tag": "Payroll"},
{"tag": "Audit"}
]
},
{
"addressBook": "IT Department",
"alias": "IT Team",
"tags": [
{"tag": "Help Desk"},
{"tag": "Infrastructure"},
{"tag": "Development"}
]
},
{
"addressBook": "Shared Resources",
"tags": [
{"tag": "Conference Rooms"},
{"tag": "Printers"}
]
}
]
}
{
"group": "Norge Hovedkontor",
"addressBooks": [
{
"addressBook": "Ansatte Datamaskiner",
"alias": "Ansattes PCer",
"tags": [
{"tag": "Bærbare PCer"},
{"tag": "Stasjonære PCer"},
{"tag": "Hjemmekontor"}
]
},
{
"addressBook": "Server og Infrastruktur",
"alias": "IT Systemer",
"tags": [
{"tag": "Produksjon"},
{"tag": "Utvikling"},
{"tag": "Testmiljø"}
]
}
]
}
All logs are stored in: C:\Windows\Temp\RustDeskDeploymentScripts\
Log Type | File Pattern | Description |
---|---|---|
MSI Install | msi_install_YYYYMMDD_HHMMSS.log |
Complete MSI installation log |
MSI Uninstall | msi_uninstall_YYYYMMDD_HHMMSS.log |
Complete MSI uninstallation log |
Script Install | install_YYYYMMDD_HHMMSS.log |
Installation script execution log |
Script Uninstall | uninstall_YYYYMMDD_HHMMSS.log |
Uninstallation script execution log |
Script Check | check_YYYYMMDD_HHMMSS.log |
Detection script results |
Script Assign | assign_YYYYMMDD_HHMMSS.log |
Assignment operations log |
# View latest logs
Get-ChildItem "C:\Windows\Temp\RustDeskDeploymentScripts\" |
Sort-Object LastWriteTime -Descending |
Select-Object -First 5
# Search for errors in logs
Get-ChildItem "C:\Windows\Temp\RustDeskDeploymentScripts\*.log" |
Select-String -Pattern "ERROR"
# View specific log
Get-Content "C:\Windows\Temp\RustDeskDeploymentScripts\install_20250103_143537.log"
Successful Installation:
[2025-01-03 14:35:37] [INFO] Starting RustDesk installation...
[2025-01-03 14:35:38] [SUCCESS] RustDesk installed successfully!
[2025-01-03 14:35:40] [INFO] Running assignment script...
[2025-01-03 14:35:42] [SUCCESS] Successfully assigned: Group: IT Department
Failed Assignment:
[2025-01-03 14:36:15] [ERROR] Failed to assign: Group: InvalidGroup (Exit Code: 1)
[2025-01-03 14:36:15] [WARNING] Partial success: Some assignments failed
- Check Script Logs: Review the script execution log for high-level issues
- Check MSI Logs: Review MSI verbose logs for installation problems
- Verify Network: Ensure RustDesk server API is accessible
- Validate Token: Confirm token has correct permissions and hasn't expired
- Test Manually: Run assignments manually to isolate issues
-
Secure Storage
- Never store tokens in plain text in production
- Use secure credential management systems
- Consider using Azure Key Vault for Intune deployments
-
Token Permissions
- Create tokens with minimum required permissions
- Separate tokens for different deployment scenarios
- Regular token rotation
-
Token Usage
# Secure token retrieval example $secureToken = Get-Secret -Name "RustDeskAPIToken" -Vault "Corporate" .\install.ps1 -ASSIGN "true" -TOKEN $secureToken.SecretValueText
- Use HTTPS exclusively for API communications
- Monitor API access logs
# Site-specific configuration
$sites = @{
"NYC" = @{config="nyc-config.json"; assignment="nyc-assign.json"}
"LON" = @{config="lon-config.json"; assignment="lon-assign.json"}
"TOK" = @{config="tok-config.json"; assignment="tok-assign.json"}
}
# Deploy to specific site
$site = $env:COMPUTERNAME.Substring(0,3)
if ($sites.ContainsKey($site)) {
Copy-Item $sites[$site].config "config.json" -Force
Copy-Item $sites[$site].assignment "assignment.json" -Force
.\install.ps1 -SILENT "true" -ASSIGN "true" -TOKEN $token -LOGGING "true"
}
# Assign based on computer type
$computerType = (Get-WmiObject Win32_ComputerSystem).Model
switch -Wildcard ($computerType) {
"*Laptop*" {
$assignFile = "laptop-assignment.json"
}
"*Desktop*" {
$assignFile = "desktop-assignment.json"
}
"*Server*" {
$assignFile = "server-assignment.json"
}
default {
$assignFile = "default-assignment.json"
}
}
.\install.ps1 `
-SILENT "true" `
-ASSIGN "true" `
-TOKEN $token `
-ASSIGNMENTFILE $assignFile `
-LOGGING "true"
Symptom: "No MSI file found in script directory"
Solutions:
# Solution 1: Specify explicit path
.\install.ps1 -MSIPATH "C:\Deployment\RustDesk.msi"
# Solution 2: Ensure MSI is in script directory
Copy-Item "\\server\software\RustDesk.msi" -Destination ".\"
.\install.ps1
Symptom: "Failed to assign: Group: XXX (Exit Code: 1)"
Diagnostics:
# Test token validity
& "C:\Program Files\RustDesk\RustDesk.exe" --assign --token "your-token" --device_group_name "Test" | Out-String
# Check token permissions in RustDesk server
# Settings → Tokens → Verify Read/Write for Devices and Groups
Symptom: Characters like "æøå" appear as "???"
Solution:
- Ensure assignment.json is saved with UTF-8 encoding
- Script automatically handles UTF-8 via
chcp 65001
- Verify in text editor that file encoding is UTF-8
Symptom: "cannot be loaded because running scripts is disabled"
Solution:
# For testing (temporary)
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
# For production (recommended)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
Symptom: Address books assigned but group missing
Verification:
- Confirm only one group in assignment.json (not an array)
- Check group name exists in RustDesk server
- Review assign log for specific error
Symptom: Address book created but alias missing
Requirements:
- RustDesk Server Pro 1.5.8 or later
- RustDesk Client 1.4.1 or later
- Alias must be non-empty string in assignment.json
The scripts support all RustDesk MSI public properties:
Property | Values | Description |
---|---|---|
INSTALLFOLDER | Path | Installation directory |
CREATESTARTMENUSHORTCUTS | Y/N | Create Start Menu shortcuts |
CREATEDESKTOPSHORTCUTS | Y/N | Create Desktop shortcuts |
INSTALLPRINTER | Y/N | Install virtual printer |
- UTF-8 Support: Full Unicode support via code page 65001
- File Encoding: UTF-8 without BOM for all configuration files
- Console Output: UTF-8 encoding for proper display
Code | Category | Description | Action |
---|---|---|---|
0 | Success | Operation completed successfully | None |
1 | Warning | Version mismatch (check.ps1) | Review |
1603 | Error | Fatal error during operation | Investigate logs |
1605 | Not Found | Product not installed | Expected for new installs |
1619 | Access Error | MSI package could not be opened | Check file permissions |
1638 | Version Error | Another version already installed | Uninstall first |
3010 | Reboot | Success but reboot required | Schedule reboot |
- Documentation: Review this README and script comments
- Logs: Check logs in
C:\Windows\Temp\RustDeskDeploymentScripts\
- Issues: Report bugs on GitHub with logs and environment details
- Testing: Always test in non-production environment first
I welcome contributions! Please:
- Fork the repository
- Create a feature branch
- Test thoroughly
- Submit pull request with detailed description