# Create folder
$folder = 'c:\data'
New-Item -Path $folder -type directory -Force
# User(s) ID and Access Rule
$id = 'authenticated users'
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule -argumentlist ($id,"FullControl","ContainerInherit, ObjectInherit","None","Allow")
# Get the current ACL from newly created folder
$setACL = Get-ACL $folder
# Add the new Access Rule to the Current Rule
$setACL.AddAccessRule($accessRule)
# Set the new access rule on the new folder
Set-ACL -Path $folder -ACLObject $setACL
$folder = 'c:\data'
New-Item -Path $folder -type directory -Force
# User(s) ID and Access Rule
$id = 'authenticated users'
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule -argumentlist ($id,"FullControl","ContainerInherit, ObjectInherit","None","Allow")
# Get the current ACL from newly created folder
$setACL = Get-ACL $folder
# Add the new Access Rule to the Current Rule
$setACL.AddAccessRule($accessRule)
# Set the new access rule on the new folder
Set-ACL -Path $folder -ACLObject $setACL
Comments
Post a Comment