Last active
April 15, 2016 09:40
-
-
Save micmaher/475df2ad41ac4a0123ea59baa3f5e3de to your computer and use it in GitHub Desktop.
Change Citrix Permissions to meet AGDLP rule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$csvFile = "C:\temp\CtxGroups2.csv" | |
import-module activeDirectory | |
############################### 1. Get the Citrix Groups ################################ | |
# Run in MWTRADERS Domain | |
Get-ADGroup -Filter * -SearchBase "ou=Retail,ou=Dublin,dc=contoso,dc=com" | Select Name, distinguishedName | Export-Csv $csvFile | |
break | |
################################ 2. Create a Domain Local equivalent on IE ################################ | |
# Run in IE Domain | |
$ctxGroups = Import-csv $csvFile -useCulture | |
foreach ($group in $ctxGroups) | |
{ | |
if ($group) | |
{ | |
Log-Write "Creating DL_$($group.name)" | |
$DomainLocalEquiv = "DL_" + $group.name | |
#New-ADGroup -name $DomainLocalEquiv -path "ou=Citrix,ou=Domain Local,ou=security groups,dc=contoso,dc=com" -GroupScope DomainLocal -GroupCategory Security | |
} | |
} | |
break | |
############################### 3. Create a Global equivalent on CONTOSO ################################ | |
# Run in NWTRADERS | |
$ctxGroups = Import-csv $csvFile -useCulture | |
foreach ($group in $ctxGroups) | |
{ | |
if ($group) | |
{ | |
Log-Write "Creating $($group.name)" | |
New-ADGroup -name $group.name -path "ou=Global,ou=Citrix,ou=security groups,dc=nwtraders,dc=com" -GroupScope Global -GroupCategory Security | |
} | |
} | |
break | |
############################### 4. Create a Domain Local equivalent on AD ################################ | |
# Run in NWTRADERS | |
$ctxGroups = Import-csv $csvFile -useCulture | |
foreach ($group in $ctxGroups) | |
{ | |
if ($group) | |
{ | |
Log-Write "Creating DL_$($group.name)" | |
$DomainLocalEquiv = "DL_" + $group.name | |
New-ADGroup -name $DomainLocalEquiv -path "ou=Domain Local,ou=Citrix,ou=security groups,dc=nwtraders,dc=com" -GroupScope DomainLocal -GroupCategory Security | |
} | |
} | |
break | |
############################### 5. Add the NWTraders Global Group to the Domain Local equivalent in NWTraders ############################### | |
# Run in NWTRADERS | |
$ctxGroups = Import-csv $csvFile -useCulture | |
foreach ($group in $ctxGroups) | |
{ | |
if ($group) | |
{ | |
Log-Write "Add to DL_$($group.name) - $($group.name)" | |
Add-ADGroupMember DL_$($group.name) $group.name | |
} | |
} | |
break | |
############################### 6. Add the NWTraders Global Group to the Domain Local equivalent in Contoso ################################ | |
# Run in CONTOSO | |
$ctxGroups = Import-csv $csvFile -useCulture | |
foreach ($group in $ctxGroups) | |
{ | |
if ($group) | |
{ | |
$forestADGroup = Get-ADGroup $group.name -server "nwtraders.com" | |
Add-ADGroupMember DL_$($group.name) -members $forestADGroup | |
Log-Write "Added to DL_$($group.name) - $($forestADGroup)" | |
} | |
} | |
break | |
############################### 7. Add the CONTOSO Global Group to the Domain Local equivalent in CONTOSO ################################ | |
Run in CONTOSO | |
$ctxGroups = Import-csv $csvFile -useCulture | |
foreach ($group in $ctxGroups) | |
{ | |
if ($group) | |
{ | |
Add-ADGroupMember "DL_$($group.name)" -members $group.name | |
Log-Write "Added to DL_$($group.name) - $($group)" | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment