Last active
December 17, 2015 05:29
-
-
Save glallen01/5558172 to your computer and use it in GitHub Desktop.
Create Domain Local And Global Groups, with nesting.
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
set DOMAIN=DC=Contoso,DC=COM | |
set FLAGS=-pwd "P@$$w0rd" -mustchpwd no -disabled yes | |
for /f "delims=" %%G IN (units.txt) do ( | |
dsadd ou "OU=%%G,%DOMAIN%" | |
dsadd ou "OU=Users,OU=%%G,%DOMAIN%" | |
dsadd ou "OU=Computers,OU=%%G,%DOMAIN%" | |
dsadd group "CN=DL_%%G_WorkstationAdmin,OU=Users,OU=%%G,%DOMAIN%" -scope l | |
dsadd group "CN=GG_%%G_WorkstationAdmin,OU=Users,OU=%%G,%DOMAIN%" -scope g -memberof "CN=DL_%%G_WorkstationAdmin,OU=Users,OU=%%G,%DOMAIN%" | |
dsadd user "CN=%%G.Template,OU=Users,OU=%%G,%DOMAIN%" | |
) | |
set TGT=OU=Users,OU=....,%DOMAIN% | |
set TGTGRP=CN=.....,OU=....,%DOMAIN% | |
dsadd group %TGTGRP% | |
for /f "tokens=1,2 delims=," %%G in (users.txt) do ( | |
dsadd user "CN=%%H,%%G,%TGT%" -fn %%H -ln %%G %FLAGS% -memberof %TGTGRP% | |
) | |
Get-ChildItem -path C:\share -recurse | where { $_.Fullname -match "PRIVATE" } | %{ get-acl $_.FullName } |
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
set DOMAIN=DC=Contoso,DC=COM | |
for /f "delims=" %%G IN (units.txt) do ( | |
dsadd group "CN=DL_%%G_WorkstationAdmin,OU=%%G,%DOMAIN%" -scope l | |
dsadd group "CN=GG_%%G_WorkstationAdmin,OU=%%G,%DOMAIN%" -scope g -memberof "CN=DL_%%G_WorkstationAdmin,OU=%%G,%DOMAIN%" | |
) | |
set FLAGS=-pwd "P@$$w0rd" -mustchpwd no -disabled no | |
set TARGETOU=OU=SUBOU,OU=Users,OU=Unit,%DOMAIN% | |
dsadd ou "%TARGETOU%" | |
for /f "tokens=1,2 delims=," %%G IN (users.txt) DO ( | |
dsadd user "CN=%%H.%%G,%TARGETOU% -fn %%H -ln %%G %FLAGS% | |
) | |
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
set DOMAIN=DC=Contoso,DC=COM | |
set FLAGS=-pwd "P@$$w0rd" -mustchpwd no -disabled yes | |
set ADD=OU=Users | |
for /f "delims=" %%G IN (units.txt) do ( | |
dsadd ou "OU=%%G,%DOMAIN%" | |
dsadd ou "%ADD%,OU=%%G,%DOMAIN%" | |
dsadd user "CN=%%G.Template,%ADD%,OU=%%G,%DOMAIN%" %FLAGS% | |
dsadd ou "OU=Computers,OU=%%G,%DOMAIN%" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment