Answered by:
Set-ACL modify permission

Question
-
Hi
I have csv files in which i have samaccountname and homdirectory path of everyuser.
Now I need to set SamAccountanme modify permission on the homdirectory path mentioined in CSV file.
CSV file format as below:
SamAccountName HomeDirectory
flast1 \\file-vs6\sharefolder\%username%
flast2 \\file-vs6\sharefolder\%username%
flast3 \\file-vs6\sharefolder\%username%
flast4 \\file-vs6\sharefolder\%username%
Please guide or help on this..
Monday, October 7, 2013 10:37 AM
Answers
-
Hi,
Thanks for your posting.
The script below describes a way to bulk import users using a csv file as input with PowerShell and sets the correct permissions. Which maybe helpful for you to complete the target.
Import-Module ActiveDirectory #Clear the screen Clean-Host #Determine location of input file $file = Read-Host "Location of the csv file (for example c:\temp\importusers) $homepath = "\\file-vs6\sharefolder" #Setting Permission on new Home drive folder Import-csv $file -Delimiter ';'| ForEach-Object { $user = $_.SamAccountName $acl = get-acl $homepath\$user $acl.SetAccessRuleProtection($True, $True) $rule = New-Object System.Security.AccessControl.FileSystemAccessRule("$user","Modify", "ContainerInherit, ObjectInherit", "None", "Allow") $acl.AddAccessRule($rule) Set-Acl $homepath\$user $acl} Write-Host "All Done!"
For detailed information about the script, please refer to this article:
Bulk Import User Accounts with PowerShell:
I hope this helps.
- Marked as answer by AnnaWY Monday, October 14, 2013 3:58 PM
Tuesday, October 8, 2013 7:33 AM
All replies
-
Hi,
Thanks for your posting.
The script below describes a way to bulk import users using a csv file as input with PowerShell and sets the correct permissions. Which maybe helpful for you to complete the target.
Import-Module ActiveDirectory #Clear the screen Clean-Host #Determine location of input file $file = Read-Host "Location of the csv file (for example c:\temp\importusers) $homepath = "\\file-vs6\sharefolder" #Setting Permission on new Home drive folder Import-csv $file -Delimiter ';'| ForEach-Object { $user = $_.SamAccountName $acl = get-acl $homepath\$user $acl.SetAccessRuleProtection($True, $True) $rule = New-Object System.Security.AccessControl.FileSystemAccessRule("$user","Modify", "ContainerInherit, ObjectInherit", "None", "Allow") $acl.AddAccessRule($rule) Set-Acl $homepath\$user $acl} Write-Host "All Done!"
For detailed information about the script, please refer to this article:
Bulk Import User Accounts with PowerShell:
I hope this helps.
- Marked as answer by AnnaWY Monday, October 14, 2013 3:58 PM
Tuesday, October 8, 2013 7:33 AM -
Hi
I have CSV file and while trying to create directory on file server, gets error but when i specify the path of file server as $homepath = \\fileserver\sharefoldername then its works fine..
I need to import homepath from csv file .. instead of specifying in the script..
Wednesday, October 9, 2013 11:18 PM