Skip to content

RDP - Gateway connection handling

Add Monitoring for Windows GCE Agents (https://app.clickup.com/t/86c67rj3r) Investigate AO RDP not responding (https://app.clickup.com/t/86c65rxx2) Restart GCE Agent from RDSGW-01 (https://app.clickup.com/t/86c8nwgbt)

Introduction

GCE Agent will handle passthrough Load Balancer. It means it will keep up RDP connection.

Monitoring

[

dash.aholadigital.com

https://dash.aholadigital.com/d/ce1mqtbp9vcw0d/service-desk-ahola?orgId=1&from=now-15m&to=now&timezone=browser&refresh=5m&editIndex=0&viewPanel=panel-58

](https://dash.aholadigital.com/d/ce1mqtbp9vcw0d/service-desk-ahola?orgId=1&from=now-15m&to=now&timezone=browser&refresh=5m&editIndex=0&viewPanel=panel-58)

Load Balancers

[

console.cloud.google.com

https://console.cloud.google.com/net-services/loadbalancing/list/loadBalancers?referrer=search&project=common-servers-01

](https://console.cloud.google.com/net-services/loadbalancing/list/loadBalancers?referrer=search&project=common-servers-01)

  • lb-rdgw-udp
  • lb-rdgw-tcp

Script to check status and start service if its stopped

# Define the service name(s). 
$ServiceNames = @("google-guest-agent", "GCEAgent")
$ServiceNameFound = $null

# --- 1. Identify the Service ---
foreach ($Name in $ServiceNames) {
    $Service = Get-Service -Name $Name -ErrorAction SilentlyContinue
    if ($Service) {
        $ServiceNameFound = $Name
        break 
    }
}

if (-not $ServiceNameFound) {
    Write-Warning "GCE Guest Agent service not found. Aborting."
    exit 1
}

# --- 2. Check and Repair Startup Type ---
# We use Get-CimInstance or Get-Service (v6+) to check the StartType
$ServiceObj = Get-Service -Name $ServiceNameFound

if ($ServiceObj.StartType -eq 'Disabled') {
    Write-Host "Detected '$ServiceNameFound' is DISABLED. Resetting to Automatic..." -ForegroundColor Yellow
    Set-Service -Name $ServiceNameFound -StartupType Automatic
}

# --- 3. Manage Running Status ---
if ($ServiceObj.Status -ne "Running") {
    Write-Host "Service is $($ServiceObj.Status). Attempting to start..."

    try {
        Start-Service -Name $ServiceNameFound -ErrorAction Stop

        # Poll for status update
        Start-Sleep -Seconds 5
        $ServiceObj = Get-Service -Name $ServiceNameFound 

        if ($ServiceObj.Status -eq "Running") {
            Write-Host "? SUCCESS: '$ServiceNameFound' is now Running." -ForegroundColor Green
        } else {
            Write-Error "? FAILED: Service is in state: $($ServiceObj.Status)."
        }
    }
    catch {
        Write-Error "An error occurred: $($_.Exception.Message)"
    }
} else {
    Write-Host "? '$ServiceNameFound' is already Running." -ForegroundColor Green
  • } Saved as Start-GCEAgent.ps1 to both GW's C:\scripts

Output

PS C:\Windows\system32> C:\temp\Start-GCEAgent.ps1
Service 'GCEAgent' found.
Current status of 'Google Compute Engine Agent' is: Stopped
Service is stopped. Attempting to start the service...

Status   Name               DisplayName                           
------   ----               -----------                           
Running  GCEAgent           Google Compute Engine Agent           
SUCCESS: The 'Google Compute Engine Agent' service is now Running.

PS C:\Windows\system32> C:\temp\Start-GCEAgent.ps1
Service 'GCEAgent' found.
Current status of 'Google Compute Engine Agent' is: Running
The 'Google Compute Engine Agent' service is already Running. No action needed.

Both GW servers has scheduled task to maintain GCEAgent * Task will trigger every day at 05:00 and repeat in every 30min during 24h


Manual Steps

There is couple ways to check GCEAgent status manually 1. Option 1 | Login to Gateway server 1. Open Services → find Google Compute Engine Agent → check status (Running | Stopped | etc) 2. Option 2 | Login to Gateway Server 1. Open Powershell as admin and run : 2. Get-Service -Name GCEAgent 1. output will be like:

PS C:\Windows\system32> Get-Service -Name GCEAgent
Status   Name               DisplayName
------   ----               -----------
Running  GCEAgent           Google Compute Engine Agent
2. If service is stopped → run: 3. Start-Service GCEAgent options (Start | Stop | Restart) 3. Option 3 | Open PowerShell as admin for ex jump -server 1. Run Enter-PSSession -ComputerName rdsgw-02 (change computer name to wanted dest server) 1. repeat steps b - iii from Option 2