Thursday, February 20, 2025

Using Powershell in Action1 to update RustDesk

Using Powershell in Action1 to update RustDesk

This script can be used to install and update RustDesk using Action1.  Action1 is a wonderful cloud based patch management system, though I can create an on prem solution for deploying RustDesk, it was decided that we needed to be able to deploy updates for the software to users at home as well for remote support options as RustDesk is more responsive and faster than Action1.  This can be run as a custom script created and saved in the script library in action1 


or it can be run directly on the endpoint if it is a script you don't need to run over again which can be found near the actions column in action 1.



Below is the powershell script for updating/installing RustDesk.  If you have your own rustdesk server this WILL keep your settings when updating.

##START COPY

$Folder = 'c:\itTemp'

$URL = 'https://github.com/rustdesk/rustdesk/releases/download/1.3.7/rustdesk-1.3.7-x86_64.msi'

##"Test to see if folder [$Folder]  exists"

if (Test-Path -Path $Folder) {

##If it exsists remove it

Remove-Item 'c:\itTemp' -Force

##Is RustDesk Installed?  If it is uninstall it.

Get-CimInstance -ClassName win32_product | Where-Object Name -Match "RustDesk" | 

    ForEach-Object -Process { 

        Invoke-CimMethod -InputObject $_ -Name Uninstall 

                            }

##Create a temporary folder, download the latest version of RustDesk and install it

New-Item -Path "c:\" -Name "itTemp" -ItemType "directory"

Invoke-WebRequest https://github.com/rustdesk/rustdesk/releases/download/1.3.7/rustdesk-1.3.7-x86_64.msi -OutFile c:\itTemp\rustdesk-1.3.7-x86_64.msi

$pkg = "c:\itTemp\rustdesk-1.3.7-x86_64.msi";

Start-Process msiexec "/i $pkg /norestart /qn" -Wait;

##Wait 30 seconds before removing the directory

Start-Sleep -Seconds 30

##Clean up garbage

Remove-Item -Recurse -Force c:\itTemp\*.*

Remove-Item 'c:\itTemp' -Force

} else {

##If the itTemp folder doesn't exsits remove rustdesk 

Get-CimInstance -ClassName win32_product | Where-Object Name -Match "RustDesk" | 

    ForEach-Object -Process { 

        Invoke-CimMethod -InputObject $_ -Name Uninstall 

                            }

##Create a temporary folder, download the latest version of RustDesk and install it                            

New-Item -Path "c:\" -Name "itTemp" -ItemType "directory"

Invoke-WebRequest https://github.com/rustdesk/rustdesk/releases/download/1.3.7/rustdesk-1.3.7-x86_64.msi -OutFile c:\itTemp\rustdesk-1.3.7-x86_64.msi

$pkg = "c:\itTemp\rustdesk-1.3.7-x86_64.msi";

Start-Process msiexec "/i $pkg /norestart /qn" -Wait;

##Wait 30 seconds before removing the directory

Start-Sleep -Seconds 30

##Clean up garbage

Remove-Item -Recurse -Force c:\itTemp\*.*

Remove-Item 'c:\itTemp'

}

##END COPY

Using Powershell in Action1 to update RustDesk

Using Powershell in Action1 to update RustDesk This script can be used to install and update RustDesk using Action1.  Action1 is a wonderf...