scripts/AD_AIO.ps1 aktualisiert
This commit is contained in:
@@ -153,6 +153,7 @@ function Create-User {
|
|||||||
$outputTextBox.Location = New-Object System.Drawing.Point(10, 350) # Position unterhalb des DataGridViews
|
$outputTextBox.Location = New-Object System.Drawing.Point(10, 350) # Position unterhalb des DataGridViews
|
||||||
$outputTextBox.Size = New-Object System.Drawing.Size(954, 150) # Größe der RichTextBox festgelegt
|
$outputTextBox.Size = New-Object System.Drawing.Size(954, 150) # Größe der RichTextBox festgelegt
|
||||||
$outputTextBox.ScrollBars = 'Vertical'
|
$outputTextBox.ScrollBars = 'Vertical'
|
||||||
|
$outputTextBox.ReadOnly = $true
|
||||||
$form.Controls.Add($outputTextBox)
|
$form.Controls.Add($outputTextBox)
|
||||||
|
|
||||||
# OK-Button erstellen
|
# OK-Button erstellen
|
||||||
@@ -331,7 +332,7 @@ function Create-User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Formular anzeigen
|
# Formular anzeigen
|
||||||
$form.ShowDialog()
|
$form.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
# Funktion, die beim Klick auf "Create Groups" ausgeführt wird
|
# Funktion, die beim Klick auf "Create Groups" ausgeführt wird
|
||||||
@@ -395,6 +396,7 @@ function Create-Groups {
|
|||||||
$outputTextBox.Location = New-Object System.Drawing.Point(10, 320) # Position unterhalb des DataGridViews
|
$outputTextBox.Location = New-Object System.Drawing.Point(10, 320) # Position unterhalb des DataGridViews
|
||||||
$outputTextBox.Size = New-Object System.Drawing.Size(564, 150) # Größe der RichTextBox
|
$outputTextBox.Size = New-Object System.Drawing.Size(564, 150) # Größe der RichTextBox
|
||||||
$outputTextBox.ScrollBars = 'Vertical'
|
$outputTextBox.ScrollBars = 'Vertical'
|
||||||
|
$outputTextBox.ReadOnly = $true
|
||||||
$form.Controls.Add($outputTextBox)
|
$form.Controls.Add($outputTextBox)
|
||||||
|
|
||||||
# OK-Button für Gruppen erstellen
|
# OK-Button für Gruppen erstellen
|
||||||
@@ -411,7 +413,7 @@ function Create-Groups {
|
|||||||
|
|
||||||
if (-not $groupType -or -not $groupName -or -not $groupOU) {
|
if (-not $groupType -or -not $groupName -or -not $groupOU) {
|
||||||
$outputTextBox.SelectionColor = 'Red'
|
$outputTextBox.SelectionColor = 'Red'
|
||||||
$outputTextBox.AppendText("Fehler: Alle Felder (Typ, Gruppenname, OU) müssen ausgefüllt sein.`r`n")
|
$outputTextBox.AppendText("Fehler: Alle Felder (Typ, Gruppenname, OU) müssen ausgefüllt sein.`r`n")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,7 +434,7 @@ function Create-Groups {
|
|||||||
New-ADGroup -Name $groupName `
|
New-ADGroup -Name $groupName `
|
||||||
-GroupScope Global `
|
-GroupScope Global `
|
||||||
-Path $groupOU `
|
-Path $groupOU `
|
||||||
-Description "Globale Gruppe für $groupName"
|
-Description "Globale Gruppe für $groupName"
|
||||||
$outputTextBox.SelectionColor = 'Green'
|
$outputTextBox.SelectionColor = 'Green'
|
||||||
$outputTextBox.AppendText("Globale Gruppe '$groupName' wurde erfolgreich erstellt.`r`n")
|
$outputTextBox.AppendText("Globale Gruppe '$groupName' wurde erfolgreich erstellt.`r`n")
|
||||||
} else {
|
} else {
|
||||||
@@ -446,7 +448,7 @@ function Create-Groups {
|
|||||||
New-ADGroup -Name $domainLocalGroupName `
|
New-ADGroup -Name $domainLocalGroupName `
|
||||||
-GroupScope DomainLocal `
|
-GroupScope DomainLocal `
|
||||||
-Path $groupOU `
|
-Path $groupOU `
|
||||||
-Description "DomainLocal Gruppe für $domainLocalGroupName"
|
-Description "DomainLocal Gruppe für $domainLocalGroupName"
|
||||||
$outputTextBox.SelectionColor = 'Green'
|
$outputTextBox.SelectionColor = 'Green'
|
||||||
$outputTextBox.AppendText("DomainLocal Gruppe '$domainLocalGroupName' wurde erfolgreich erstellt.`r`n")
|
$outputTextBox.AppendText("DomainLocal Gruppe '$domainLocalGroupName' wurde erfolgreich erstellt.`r`n")
|
||||||
} else {
|
} else {
|
||||||
@@ -463,7 +465,7 @@ function Create-Groups {
|
|||||||
New-ADGroup -Name $domainLocalGroupName `
|
New-ADGroup -Name $domainLocalGroupName `
|
||||||
-GroupScope DomainLocal `
|
-GroupScope DomainLocal `
|
||||||
-Path $groupOU `
|
-Path $groupOU `
|
||||||
-Description "DomainLocal Gruppe für $domainLocalGroupName"
|
-Description "DomainLocal Gruppe für $domainLocalGroupName"
|
||||||
$outputTextBox.SelectionColor = 'Green'
|
$outputTextBox.SelectionColor = 'Green'
|
||||||
$outputTextBox.AppendText("DomainLocal Gruppe '$domainLocalGroupName' wurde erfolgreich erstellt.`r`n")
|
$outputTextBox.AppendText("DomainLocal Gruppe '$domainLocalGroupName' wurde erfolgreich erstellt.`r`n")
|
||||||
} else {
|
} else {
|
||||||
@@ -495,7 +497,7 @@ function Create-Groups {
|
|||||||
$form.Controls.Add($exitButton)
|
$form.Controls.Add($exitButton)
|
||||||
|
|
||||||
# Formular anzeigen
|
# Formular anzeigen
|
||||||
$form.ShowDialog()
|
$form.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
# Funktion, die beim Klick auf "ADGDL" ausgeführt wird
|
# Funktion, die beim Klick auf "ADGDL" ausgeführt wird
|
||||||
@@ -504,7 +506,7 @@ function ADGDL {
|
|||||||
Add-Type -AssemblyName System.Windows.Forms
|
Add-Type -AssemblyName System.Windows.Forms
|
||||||
Import-Module ActiveDirectory
|
Import-Module ActiveDirectory
|
||||||
|
|
||||||
# Funktion zum Abrufen der aktuellen Domäne
|
# Funktion zum Abrufen der aktuellen Domäne
|
||||||
function Get-DomainName {
|
function Get-DomainName {
|
||||||
$domain = (Get-ADDomain).DNSRoot
|
$domain = (Get-ADDomain).DNSRoot
|
||||||
return $domain
|
return $domain
|
||||||
@@ -531,7 +533,7 @@ function ADGDL {
|
|||||||
# GUI zur Zuordnung von GG zu DL und Benutzern erstellen
|
# GUI zur Zuordnung von GG zu DL und Benutzern erstellen
|
||||||
$form = New-Object System.Windows.Forms.Form
|
$form = New-Object System.Windows.Forms.Form
|
||||||
$form.Text = "GG zu DL Zuordnung und Benutzer"
|
$form.Text = "GG zu DL Zuordnung und Benutzer"
|
||||||
$form.Size = New-Object System.Drawing.Size(805, 435) # Fenstergröße anpassen
|
$form.Size = New-Object System.Drawing.Size(805, 505) # Fenstergröße anpassen
|
||||||
|
|
||||||
# Benutzer-Eingabe und Liste (ganz oben)
|
# Benutzer-Eingabe und Liste (ganz oben)
|
||||||
$userLabel = New-Object System.Windows.Forms.Label
|
$userLabel = New-Object System.Windows.Forms.Label
|
||||||
@@ -585,7 +587,7 @@ function ADGDL {
|
|||||||
|
|
||||||
# DL-Eingabe und Liste (ganz unten)
|
# DL-Eingabe und Liste (ganz unten)
|
||||||
$dlLabel = New-Object System.Windows.Forms.Label
|
$dlLabel = New-Object System.Windows.Forms.Label
|
||||||
$dlLabel.Text = "Domänenlokale Gruppen (DL):"
|
$dlLabel.Text = "Domänenlokale Gruppen (DL):"
|
||||||
$dlLabel.Location = New-Object System.Drawing.Point(530, 10)
|
$dlLabel.Location = New-Object System.Drawing.Point(530, 10)
|
||||||
$dlLabel.Size = New-Object System.Drawing.Size(250, 20)
|
$dlLabel.Size = New-Object System.Drawing.Size(250, 20)
|
||||||
$form.Controls.Add($dlLabel)
|
$form.Controls.Add($dlLabel)
|
||||||
@@ -608,10 +610,12 @@ function ADGDL {
|
|||||||
$dlListBox.Items.AddRange($filteredDLs)
|
$dlListBox.Items.AddRange($filteredDLs)
|
||||||
})
|
})
|
||||||
|
|
||||||
# RichTextBox für Debug-Informationen hinzufügen
|
# RichTextBox für Debug-Informationen hinzufügen
|
||||||
$debugTextBox = New-Object System.Windows.Forms.RichTextBox
|
$debugTextBox = New-Object System.Windows.Forms.RichTextBox
|
||||||
|
$debugTextBox.Multiline = $true
|
||||||
$debugTextBox.Location = New-Object System.Drawing.Point(10, 265)
|
$debugTextBox.Location = New-Object System.Drawing.Point(10, 265)
|
||||||
$debugTextBox.Size = New-Object System.Drawing.Size(770, 80)
|
$debugTextBox.Size = New-Object System.Drawing.Size(770, 150)
|
||||||
|
$debugTextBox.ScrollBars = 'Vertical'
|
||||||
$debugTextBox.ReadOnly = $true
|
$debugTextBox.ReadOnly = $true
|
||||||
$form.Controls.Add($debugTextBox)
|
$form.Controls.Add($debugTextBox)
|
||||||
|
|
||||||
@@ -631,7 +635,7 @@ function ADGDL {
|
|||||||
# OK-Button
|
# OK-Button
|
||||||
$okButton = New-Object System.Windows.Forms.Button
|
$okButton = New-Object System.Windows.Forms.Button
|
||||||
$okButton.Text = "OK"
|
$okButton.Text = "OK"
|
||||||
$okButton.Location = New-Object System.Drawing.Point(10, 355)
|
$okButton.Location = New-Object System.Drawing.Point(10, 425)
|
||||||
$okButton.Size = New-Object System.Drawing.Size(380, 30)
|
$okButton.Size = New-Object System.Drawing.Size(380, 30)
|
||||||
$okButton.Add_Click({
|
$okButton.Add_Click({
|
||||||
$gg = $ggListBox.SelectedItem
|
$gg = $ggListBox.SelectedItem
|
||||||
@@ -642,7 +646,7 @@ function ADGDL {
|
|||||||
foreach ($user in $users) {
|
foreach ($user in $users) {
|
||||||
if (-not (Get-ADGroupMember -Identity $gg -Recursive | Where-Object { $_.SamAccountName -eq $user })) {
|
if (-not (Get-ADGroupMember -Identity $gg -Recursive | Where-Object { $_.SamAccountName -eq $user })) {
|
||||||
Add-ADGroupMember -Identity $gg -Members $user
|
Add-ADGroupMember -Identity $gg -Members $user
|
||||||
Add-DebugMessage "Benutzer $user wurde der Globalgruppe $gg hinzugefügt." "Green"
|
Add-DebugMessage "Benutzer $user wurde der Globalgruppe $gg hinzugefügt." "Green"
|
||||||
} else {
|
} else {
|
||||||
Add-DebugMessage "Benutzer $user ist bereits Mitglied der Globalgruppe $gg." "Orange"
|
Add-DebugMessage "Benutzer $user ist bereits Mitglied der Globalgruppe $gg." "Orange"
|
||||||
}
|
}
|
||||||
@@ -655,7 +659,7 @@ function ADGDL {
|
|||||||
if ($groupType -eq 'Global') {
|
if ($groupType -eq 'Global') {
|
||||||
if (-not (Get-ADGroupMember -Identity $dlGroup -Recursive | Where-Object { $_.SamAccountName -eq $gg })) {
|
if (-not (Get-ADGroupMember -Identity $dlGroup -Recursive | Where-Object { $_.SamAccountName -eq $gg })) {
|
||||||
Add-ADGroupMember -Identity $dlGroup -Members $gg
|
Add-ADGroupMember -Identity $dlGroup -Members $gg
|
||||||
Add-DebugMessage "Globalgruppe $gg wurde zur Globalgruppe $dlGroup hinzugefügt." "Green"
|
Add-DebugMessage "Globalgruppe $gg wurde zur Globalgruppe $dlGroup hinzugefügt." "Green"
|
||||||
} else {
|
} else {
|
||||||
Add-DebugMessage "Globalgruppe $gg ist bereits Mitglied der Globalgruppe $dlGroup." "Orange"
|
Add-DebugMessage "Globalgruppe $gg ist bereits Mitglied der Globalgruppe $dlGroup." "Orange"
|
||||||
}
|
}
|
||||||
@@ -670,9 +674,9 @@ function ADGDL {
|
|||||||
if ($groupType -eq 'DomainLocal') {
|
if ($groupType -eq 'DomainLocal') {
|
||||||
if (-not (Get-ADGroupMember -Identity $dlGroup -Recursive | Where-Object { $_.SamAccountName -eq $gg })) {
|
if (-not (Get-ADGroupMember -Identity $dlGroup -Recursive | Where-Object { $_.SamAccountName -eq $gg })) {
|
||||||
Add-ADGroupMember -Identity $dlGroup -Members $gg
|
Add-ADGroupMember -Identity $dlGroup -Members $gg
|
||||||
Add-DebugMessage "Globalgruppe $gg wurde zur Domänenlokalen Gruppe $dlGroup hinzugefügt." "Green"
|
Add-DebugMessage "Globalgruppe $gg wurde zur Domänenlokalen Gruppe $dlGroup hinzugefügt." "Green"
|
||||||
} else {
|
} else {
|
||||||
Add-DebugMessage "Globalgruppe $gg ist bereits Mitglied der Domänenlokalen Gruppe $dlGroup." "Orange"
|
Add-DebugMessage "Globalgruppe $gg ist bereits Mitglied der Domänenlokalen Gruppe $dlGroup." "Orange"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -689,14 +693,14 @@ function ADGDL {
|
|||||||
# Beenden-Button
|
# Beenden-Button
|
||||||
$exitButton = New-Object System.Windows.Forms.Button
|
$exitButton = New-Object System.Windows.Forms.Button
|
||||||
$exitButton.Text = "Beenden"
|
$exitButton.Text = "Beenden"
|
||||||
$exitButton.Location = New-Object System.Drawing.Point(400, 355)
|
$exitButton.Location = New-Object System.Drawing.Point(400, 425)
|
||||||
$exitButton.Size = New-Object System.Drawing.Size(380, 30)
|
$exitButton.Size = New-Object System.Drawing.Size(380, 30)
|
||||||
$exitButton.Add_Click({
|
$exitButton.Add_Click({
|
||||||
$form.Close()
|
$form.Close()
|
||||||
})
|
})
|
||||||
$form.Controls.Add($exitButton)
|
$form.Controls.Add($exitButton)
|
||||||
|
|
||||||
$form.ShowDialog()
|
$form.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
# Erstellen des Formulars
|
# Erstellen des Formulars
|
||||||
|
|||||||
Reference in New Issue
Block a user