From 0aeeaee363ce5a15448c911c8e5d77b13c5ee34c Mon Sep 17 00:00:00 2001 From: Marius Raes <mariusraes@Mariuss-MacBook-Air.local> Date: Mon, 16 May 2022 09:52:51 +0200 Subject: [PATCH] try catch --- source/orchestrationLogic/HEAT/bootup.ps1 | 20 +++++++++++++++++++- source/orchestrationLogic/orchestrator.py | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/source/orchestrationLogic/HEAT/bootup.ps1 b/source/orchestrationLogic/HEAT/bootup.ps1 index 2947e7e7..8bc4ebfc 100644 --- a/source/orchestrationLogic/HEAT/bootup.ps1 +++ b/source/orchestrationLogic/HEAT/bootup.ps1 @@ -22,6 +22,8 @@ if( !(Test-Path -Path "C:\flag.txt")) { $usr = "$dc\Administrator" $creds = New-Object System.Management.Automation.PSCredential($usr,$pw) + $added = $true + $i = 0; do { try { Add-Computer -DomainName $dc -Credential $creds -ErrorAction Stop @@ -38,6 +40,22 @@ if( !(Test-Path -Path "C:\flag.txt")) { }else { echo "else" - <RDPMembers> # Adds users to the rdp member group + $added = $true + $i = 0; + do{ + + try{ + <RDPMembers> # Adds users to the rdp member group + echo "adding succeeded" + + } catch { + echo "adding faled retrying in one minute" + $added = $false + $i = $i + 1 + Start-Sleep -s 60 + } + + } while((-Not $added) -And ($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