From bba2761e00558fe698237c441af329f039c53a56 Mon Sep 17 00:00:00 2001
From: Saad Chaaban <saad.chaaban@hu-berlin.de>
Date: Sat, 16 Dec 2023 15:24:55 +0100
Subject: [PATCH] Update file createComputer_GUI.ps1

---
 windows/AD/createComputer_GUI.ps1 | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/windows/AD/createComputer_GUI.ps1 b/windows/AD/createComputer_GUI.ps1
index a1d34c4..19ff480 100644
--- a/windows/AD/createComputer_GUI.ps1
+++ b/windows/AD/createComputer_GUI.ps1
@@ -103,9 +103,9 @@ $cancelBtn                      = New-Object system.Windows.Forms.Button
 $cancelBtn.BackColor            = "#ffffff"
 $cancelBtn.text                 = " Script beenden "
 $cancelBtn.AutoSize  			= $true
-$cancelBtn.location             = New-Object System.Drawing.Point(360,350)
-$cancelBtn.Font                 = 'Microsoft Sans Serif,10'
-$cancelBtn.ForeColor            = "#000"
+$cancelBtn.location				= New-Object System.Drawing.Point(360,350)
+$cancelBtn.Font					= 'Microsoft Sans Serif,10'
+$cancelBtn.ForeColor			= "#000"
 $cancelBtn.DialogResult         = [System.Windows.Forms.DialogResult]::Cancel
 $AddADComputerForm.CancelButton = $cancelBtn
 $AddADComputerForm.Controls.Add($cancelBtn)
@@ -126,6 +126,7 @@ function enable_confirm
 	}
 }
 
+# Fügt Windows Computer in die Vordefenierten Standardgruppen hinzu
 function Add-StandardGroups {
 	Write-Host "$($ComputerName.Text)$"
 	Add-ADGroupMember grSowiSoftwareFirefoxESR -members "$($ComputerName.Text)$"
@@ -139,9 +140,6 @@ function Create-Computer {
 		-SamAccountName $($ComputerName.Text) `
 		-Path $($Department_Computer.DistinguishedName[$Department.SelectedIndex-1]) `
 		-Description $($ComputerType.Items[$ComputerType.SelectedIndex])
-		If(($($ComputerName.Text) -like "SOWI-R*") -and ($ComputerType.SelectedIndex -ne 2) -and ($ComputerType.SelectedIndex -ne 3)) {
-			Add-StandardGroups
-		}
 [System.Windows.MessageBox]::Show(@"
 Es wurden folgender Computer angelegt:
 
@@ -152,8 +150,12 @@ Bereich: 		$($Department.Items[$Department.SelectedIndex])
 Typ:		$($ComputerType.Items[$ComputerType.SelectedIndex])
 
 "@, 'Info')
+		If(($($ComputerName.Text) -like "SOWI-R*") -and ($ComputerType.SelectedIndex -ne 2) -and ($ComputerType.SelectedIndex -ne 3)) {
+			Add-StandardGroups
+		}
 	}
 	catch {
+# Gibt die Fehlermeldung aus, sofern es eine gibt. 
 [System.Windows.MessageBox]::Show(@"
 Ein Fehler ist aufgetreten:
 		
-- 
GitLab