scripts/AD_GROUPS_CREATE.ps1 aktualisiert
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
$runAsAdmin = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
$adminRole = [Security.Principal.WindowsBuiltInRole]::Administrator
|
||||
|
||||
if (-not $runAsAdmin.IsInRole($adminRole)) {
|
||||
# Relaunch the script as Administrator
|
||||
$arguments = "$($myinvocation.MyCommand.Definition)"
|
||||
Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File $arguments" -Verb RunAs
|
||||
exit
|
||||
}
|
||||
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
Import-Module ActiveDirectory
|
||||
|
||||
@@ -22,9 +32,9 @@ $dataGridView.Columns[1].Name = "Gruppenname" # Gruppenname in der zweiten Spal
|
||||
$dataGridView.Columns[2].Name = "OU" # OU in der dritten Spalte
|
||||
|
||||
# Breite der Spalten festlegen
|
||||
$dataGridView.Columns[0].Width = 50 # Typ-Spalte auf 50 Pixel setzen
|
||||
$dataGridView.Columns[0].Width = 75 # Typ-Spalte auf 50 Pixel setzen
|
||||
$dataGridView.Columns[1].Width = 100 # Gruppenname-Spalte auf 100 Pixel setzen
|
||||
$dataGridView.Columns[2].Width = 370 # OU-Spalte auf 400 Pixel setzen
|
||||
$dataGridView.Columns[2].Width = 345 # OU-Spalte auf 400 Pixel setzen
|
||||
|
||||
# Dropdown für den Typ (GG oder DL)
|
||||
$typColumn = New-Object System.Windows.Forms.DataGridViewComboBoxColumn
|
||||
@@ -35,7 +45,7 @@ $typColumn.Items.Add("DL_OS")
|
||||
$dataGridView.Columns.RemoveAt(0)
|
||||
$dataGridView.Columns.Insert(0, $typColumn)
|
||||
# Breite der Typ-Spalte setzen
|
||||
$typColumn.Width = 50 # Du kannst hier den Wert nach Bedarf anpassen
|
||||
$typColumn.Width = 75 # Du kannst hier den Wert nach Bedarf anpassen
|
||||
|
||||
# Dropdown für die OU-Auswahl in der dritten Spalte
|
||||
$ouColumn = New-Object System.Windows.Forms.DataGridViewComboBoxColumn
|
||||
@@ -48,7 +58,7 @@ $dataGridView.Columns.RemoveAt(2)
|
||||
$dataGridView.Columns.Insert(2, $ouColumn)
|
||||
|
||||
# Breite der OU-Spalte setzen
|
||||
$ouColumn.Width = 370 # Du kannst hier den Wert nach Bedarf anpassen
|
||||
$ouColumn.Width = 345 # Du kannst hier den Wert nach Bedarf anpassen
|
||||
|
||||
# RichTextBox für Ausgaben
|
||||
$outputTextBox = New-Object System.Windows.Forms.RichTextBox
|
||||
@@ -102,6 +112,7 @@ $okButton.Add_Click({
|
||||
}
|
||||
} elseif ($groupType -eq "DL_OS") {
|
||||
# DomainLocal Gruppen ohne Suffix erstellen
|
||||
$domainLocalGroupName = "$groupName"
|
||||
if (-not $group) {
|
||||
New-ADGroup -Name $domainLocalGroupName `
|
||||
-GroupScope DomainLocal `
|
||||
|
||||
Reference in New Issue
Block a user