Skip to main content
Pre-requisite to install RMM
S
Written by Sam
Updated over 4 months ago

Script will check the below mention points

  • Powershell version 5.1 or later

  • System Disk Storage available space

  • Processor architecture

  • Registry if it can set, get and delete

  • Is gorelo Api url's whitelist

  • Event log read/write permission

  • Backchannel API Powershell

Scripts for Pre-requisite to install RMM

Powershell version 5.1 or later

#Powershell version 5.1 or later
$requiredVersion = [version]'5.1';
$installedVersion = $PSVersionTable.PSVersion;
if ($installedVersion -lt $requiredVersion) {
Write-Host "Error: PowerShell version $($installedVersion.Major).$($installedVersion.Minor) is below the required version $($requiredVersion.Major).$($requiredVersion.Minor). Upgrade to a newer version to run this script.";
}

System Disk Storage available space

#500 mb storage
#GET System DRIVE SPACE
$systemDrive = (Get-WmiObject Win32_OperatingSystem).SystemDrive;
if($systemDrive){
$driveInfo = Get-PSDrive -PSProvider FileSystem | Where-Object { $_.Name -eq $systemDrive[0] };
if ($driveInfo) {
$freeSpaceMB = [math]::Round($driveInfo.Free / 1MB, 2);
if($freeSpaceMB -le 300){
Write-Host "Warning: Free space is less than 300 MB!";
}
}
}
else {
Write-Host "Warning: Failed to get System Drive!";
}

Processor Architecture

#64-bit operating system
#Processor Architecture
$processorArchitecture = $env:PROCESSOR_ARCHITECTURE;
if ($processorArchitecture -eq "AMD64") {
# Write-Host "64-bit processor architecture detected."
} elseif ($processorArchitecture -eq "x86") {
Write-Host "32-bit processor architecture detected.";
} else {
Write-Host "Unknown processor architecture: $processorArchitecture";
}

Registry if it can set, get and delete

#Registry read/write permission
#CHECK FOR REGISTRY IF IT CAN SET, GET & DELETE
try{
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Gorelo" -Name "Test" -Value ”test” -Type String -ErrorAction Stop;
$registryTestValue = (Get-ItemProperty -Path "HKLM:\\SOFTWARE\\Gorelo" -Name "Test" -ErrorAction Stop).Test ;
Remove-ItemProperty -Path "HKLM:\\SOFTWARE\\Gorelo" -Name "Test" -Force -ErrorAction Stop;
}
catch {
Write-Host "Failed to perform registry action. Error: $($_)";
}

Is Gorelo Api URL's whitelist

#Whitelist gorelo api urls
#Gorelo api
$apiUrls = "https://gorelo-rmm.azurewebsites.net","https://www.google.com/";
Foreach ($apiUrl in $apiUrls)
{
try {
$response = Invoke-webrequest -Uri $apiUrl -Method Get -UseBasicParsing;
# Check the response status code
if ($response.StatusCode -eq 200) {
#Write-Host "API request was successful."
} else {
Write-Host "API $($apiUrl) request failed with status code: $($response.StatusCode)";
}
} catch {
Write-Host "Failed to access gorelo api. Error: $_";
}
}

Event log read/write permission

#Event log read/write permission
#AppInsights logger throws permission exception on some devices
$logName = 'Application'
$sourceName = 'GoreloRmmTest'
# If the source does not exist, create it & write it
try {
if (-not[System.Diagnostics.EventLog]::SourceExists($sourceName)) {
New-EventLog -LogName $logName -Source $sourceName -ErrorAction Stop;
#Write-Host "Event source '$sourceName' created in log '$logName'."
}
Write-EventLog -LogName $logName -Source $sourceName -EventId 0 -EntryType Information -Message "This is a sample event with source '$sourceName'." -ErrorAction Stop;
}
catch {
Write-Host "Failed to perform event viewer action. Error: $_";
}

Backchannel API Powershell

# Define the URL and headers
$url = "https://r1.uw2.rmm.gorelo.io/message"
$headers = @{
DeviceId = "1"
}
try {
# Send the GET request and get the response
$response = Invoke-WebRequest -Uri $url -Headers $headers -Method Get
# Check the status code and print the appropriate message
if ($response.StatusCode -eq 204) {
Write-Output "OK"
} else {
throw "Unexpected status code: $($response.StatusCode). Response content: $($response.Content)"
}
} catch {
# Catch and display any exceptions
Write-Error "An error occurred: $_"
}

Check Environment Variable

#Check Environment Variable
$path = [System.Environment]::GetEnvironmentVariable("PATH")
if ($path -notlike "*system32*") {
Write-Output "The PATH environment variable does not contain 'system32'."
}
Did this answer your question?