Hi All,<\/p>\n
Can someone help me to build powershell script.<\/p>\n
I need to put groups in folder permission<\/p>\n
example : folder name - ALCDSB
\nI need to add a group called ALCDSB_Central with Modify permission<\/p>\n
There are 500 folders with different name
\nWe want to add only those group whose name match with folder like mentioned below:<\/p>\n
$foldername for that folder I want to add only group whose name is like $foldername_Central*<\/p>\n
-----------------------------------------------------code--------------------------------------<\/p>\n
$folderslist= Import-Csv C:\\archiveSeverTest\\folderlist.csv
\n$groupname= import-csv C:\\archiveSeverTest\\groupname.csv<\/p>\n
foreach ($f in $folderslist){<\/p>\n
$foldername=$f.name<\/p>\n
foreach ($g in $groupname){<\/p>\n
$gname=$g.name<\/p>\n
if ( $gname=“$($foldername)central<\/em>”) {<\/p>\n $acl = Get-Acl “C:\\archiveSeverTest\\21$($foldername)” $acl | Set-Acl “C:\\archiveSeverTest\\21$($foldername)” else { }<\/p>\n error code :<\/p>\n Hi All,<\/p>\n Can someone help me to build powershell script.<\/p>\n I need to put groups in folder permission<\/p>\n example : folder name - ALCDSB There are 500 folders with different name $foldername for that folder I want to add only group whose name is like $foldername_Central*<\/p>\n -----------------------------------------------------code--------------------------------------<\/p>\n $folderslist= Import-Csv C:\\archiveSeverTest\\folderlist.csv foreach ($f in $folderslist){<\/p>\n $foldername=$f.name<\/p>\n foreach ($g in $groupname){<\/p>\n $gname=$g.name<\/p>\n if ( $gname=“$($foldername)central<\/em>”) {<\/p>\n $acl = Get-Acl “C:\\archiveSeverTest\\21$($foldername)” $acl | Set-Acl “C:\\archiveSeverTest\\21$($foldername)” else { }<\/p>\n error code :<\/p>\n Happy to HELP but not a script writing service.<\/p>\n What have you tried? Where are you stuck?<\/p>\n If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n
\n$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule “$($gname)”,“Modify”,“Allow”
\n$acl.SetAccessRule($AccessRule)<\/p>\n
\n}<\/p>\n
\necho “group don’t match”
\n}
\n}<\/p>\n<\/p>","upvoteCount":2,"answerCount":13,"datePublished":"2021-07-02T14:27:09.000Z","author":{"@type":"Person","name":"spiceuser-50kto","url":"https://community.spiceworks.com/u/spiceuser-50kto"},"suggestedAnswer":[{"@type":"Answer","text":"
\nI need to add a group called ALCDSB_Central with Modify permission<\/p>\n
\nWe want to add only those group whose name match with folder like mentioned below:<\/p>\n
\n$groupname= import-csv C:\\archiveSeverTest\\groupname.csv<\/p>\n
\n$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule “$($gname)”,“Modify”,“Allow”
\n$acl.SetAccessRule($AccessRule)<\/p>\n
\n}<\/p>\n
\necho “group don’t match”
\n}
\n}<\/p>\n<\/p>","upvoteCount":2,"datePublished":"2021-07-02T14:27:09.000Z","url":"https://community.spiceworks.com/t/powershell-script/804573/1","author":{"@type":"Person","name":"spiceuser-50kto","url":"https://community.spiceworks.com/u/spiceuser-50kto"}},{"@type":"Answer","text":"