From 4ed5c1e86ad7b7ba4d1a857bee4d2719d1cd1134 Mon Sep 17 00:00:00 2001
From: Marius Raes <mariusraes@Mariuss-MacBook-Air.local>
Date: Mon, 16 May 2022 21:26:17 +0200
Subject: [PATCH] error action

---
 source/orchestrationLogic/HEAT/bootup.ps1 | 7 ++++++-
 source/orchestrationLogic/orchestrator.py | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/source/orchestrationLogic/HEAT/bootup.ps1 b/source/orchestrationLogic/HEAT/bootup.ps1
index 14f043be..4e4065e3 100644
--- a/source/orchestrationLogic/HEAT/bootup.ps1
+++ b/source/orchestrationLogic/HEAT/bootup.ps1
@@ -39,10 +39,15 @@ if( !(Test-Path -Path "C:\flag.txt")) {
     } while ((-Not $joined) -And ($i -lt 25))
 
 }else {
+    $added = $true
     $i = 0
     do {
+        try{
         <RDPMembers> # Adds users to the rdp member group
-        $i = $i+1
+        } catch{
+            $added = $false
+            $i = $i+1
+        }
 
     } while($i -lt 10)
 }
diff --git a/source/orchestrationLogic/orchestrator.py b/source/orchestrationLogic/orchestrator.py
index 0c2b7838..f639a59f 100644
--- a/source/orchestrationLogic/orchestrator.py
+++ b/source/orchestrationLogic/orchestrator.py
@@ -158,6 +158,6 @@ class Orchestrator:
     def allowRDP(self, members):
         result = ''
         for member in members:
-            result += "Add-LocalGroupMember -Group 'Remote Desktop Users' -Member '{}';".format(member)
+            result += "Add-LocalGroupMember -Group 'Remote Desktop Users' -Member '{}' -ErrorAction Stop;".format(member)
         return result
 
-- 
GitLab