-
Notifications
You must be signed in to change notification settings - Fork 0
Task 9 ‐ Integrate GPO's
Florianfro edited this page Nov 3, 2024
·
11 revisions
Alternative Script for GPO netshare
# Import the Group Policy module
Import-Module GroupPolicy
# Define variables for the GPOs and the file shares
$GPOs = @(
@{ Name = "GPO - Drive Mapping - Pool"; Path = "\\prod-loc1-dc1\Pool"; Groups = @() },
@{ Name = "GPO - Drive Mapping - Intern"; Path = "\\prod-loc1-dc1\Intern"; Groups = @() },
@{ Name = "GPO - Drive Mapping - Extern"; Path = "\\prod-loc1-dc1\Extern"; Groups = @() },
@{ Name = "GPO - Drive Mapping - Promoter"; Path = "\\prod-loc1-dc1\Abteilungen\Promoter"; Groups = @("PR") },
@{ Name = "GPO - Drive Mapping - Sekretariat"; Path = "\\prod-loc1-dc1\Abteilungen\Sekretariat"; Groups = @("SK") },
@{ Name = "GPO - Drive Mapping - Buchhaltung"; Path = "\\prod-loc1-dc1\Abteilungen\Buchhaltung"; Groups = @("BU") }
)
# Loop through each GPO definition to create and configure them
foreach ($GPO in $GPOs) {
# Create the GPO
$newGPO = New-GPO -Name $GPO.Name
# Create the drive mapping settings
$driveMapping = New-GPDriveMap -GPO $newGPO -Action Create -Path $GPO.Path -DriveLetter 'P' # Change DriveLetter as needed
# Assign the groups to the GPO
foreach ($group in $GPO.Groups) {
$groupDN = (Get-ADGroup -Filter { Name -eq $group }).DistinguishedName
if ($groupDN) {
Set-GPPermissions -Name $newGPO.Name -TargetType Group -TargetName $groupDN -PermissionLevel GpoEdit
} else {
Write-Host "Group '$group' not found."
}
}
# Optionally: Link the GPO to an OU (replace 'OU=YourOU,DC=domain,DC=com' with your OU path)
# New-GPLink -Name $newGPO.Name -Target 'OU=YourOU,DC=domain,DC=com'
}
Write-Host "GPOs created and configured successfully."
All GPO's in their corresponding Directory
GPO's Working with User from "Promoters" (except Intern/Extern):
GPO's Working with User from "Sekretariat" (except Intern/Extern):
Unbenanntes.Video.mp4