scripts/AD_USER_CREATE.ps1 aktualisiert
This commit is contained in:
@@ -6,7 +6,6 @@ if (-not $myPrincipal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::A
|
||||
Start-Process powershell -ArgumentList $arguments -Verb runAs
|
||||
Exit
|
||||
}
|
||||
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
Import-Module ActiveDirectory
|
||||
|
||||
@@ -178,6 +177,8 @@ $okButton.Add_Click({
|
||||
$password = $masterPassword
|
||||
}
|
||||
|
||||
$groupOU = $masterGroupOUComboBox.SelectedItem
|
||||
|
||||
# Überprüfen, ob notwendige Felder ausgefüllt sind
|
||||
if (-not $firstName -or -not $lastName) {
|
||||
$missingField = if (-not $firstName) { "Vorname" } elseif (-not $lastName) { "Nachname" }
|
||||
@@ -218,16 +219,17 @@ $okButton.Add_Click({
|
||||
}
|
||||
else {
|
||||
# Erfolgsnachricht für vorhandenen Benutzer
|
||||
$outputTextBox.SelectionColor = 'Green'
|
||||
$outputTextBox.SelectionColor = 'RED'
|
||||
$outputTextBox.AppendText("Benutzer $username existiert bereits.`r`n")
|
||||
$outputTextBox.AppendText("Fehlerdetails: $_`r`n")
|
||||
}
|
||||
|
||||
# Gruppenzuordnung durchführen, auch wenn der Benutzer schon existiert
|
||||
if ($globalGroup) {
|
||||
# Gruppen-OU immer auf die Master-OU setzen
|
||||
$groupOU = $masterGroupOUComboBox.SelectedItem
|
||||
try {
|
||||
# Überprüfen, ob die Gruppe existiert
|
||||
$groupOU = $masterGroupOUComboBox.SelectedItem
|
||||
$group = Get-ADGroup -Filter { Name -eq $globalGroup }
|
||||
try {
|
||||
# Gruppe erstellen, falls sie nicht existiert
|
||||
|
||||
Reference in New Issue
Block a user