Last active
August 29, 2015 14:26
-
-
Save guitarrapc/2eead693cf7452d91193 to your computer and use it in GitHub Desktop.
DSC Configuration to manage ACL
This file contains hidden or 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
configuration ACLTest | |
{ | |
$path = "C:\ACL"; | |
$hogePath = Join-Path $path "hoge"; | |
$fugaPath = Join-Path $path "fuga"; | |
Import-DSCResource -ModuleName GraniResource; | |
Node localhost | |
{ | |
File ACL | |
{ | |
DestinationPath = $path; | |
Ensure = "Present"; | |
Type = "Directory"; | |
Force = $true; | |
} | |
File Hoge | |
{ | |
DestinationPath = $hogePath; | |
Ensure = "Present"; | |
Type = "Directory"; | |
Force = $true; | |
DependsOn = "[File]ACL"; | |
} | |
File Fuga | |
{ | |
DestinationPath = $fugaPath; | |
Ensure = "Present"; | |
Type = "Directory"; | |
Force = $true; | |
DependsOn = "[File]ACL"; | |
} | |
#region Hoge Directory ACL | |
cInheritACL hogeInheritACL | |
{ | |
Path = $hogePath; | |
IsProtected = $false; #継承をする | |
PreserveInheritance = $true; | |
DependsOn = "[File]Hoge"; | |
} | |
cACL hogeACL | |
{ | |
Path = $hogePath; | |
Account = "Everyone"; | |
Rights = "FullControl"; | |
Ensure = "Present"; | |
Strict = $true; | |
DependsOn = "[cInheritACL]hogeInheritACL"; | |
} | |
#endregion | |
#region Fuga Directory ACL | |
cInheritACL fugaInheritACL | |
{ | |
Path = $fugaPath; | |
IsProtected = $true; #継承を破棄 | |
PreserveInheritance = $true; #継承破棄した際に、継承元のアクセス許可を個別のアクセス許可として明示的に持つ | |
DependsOn = "[File]Fuga"; | |
} | |
#endregion | |
} | |
} | |
ACLTest -OutputPath c:\hoge; | |
Start-DscConfiguration -Path c:\hoge -Verbose -Force -Wait; | |
# Test | |
Test-DSCConfiguration; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment