Your foreach loop should be correctly creating the directories assuming your CSV file has a column header called name
. Dump out the members of $Folder
to see what it generated using $Folder | Get-Member
. It is possible you just aren't getting the right value.
After you've created the folder then you can adjust the ACLs using Set-Acl
. I think the docs provide an example of this specific scenario here. Here's the sample with a few adjustments.
$NewAcl = $Folder | Get-Acl
$identity = "<username from CVS, including domain if needed"
$fileSystemRights = "Write"
$type = "Allow"
$fileSystemAccessRuleArgumentList = $identity, $fileSystemRights, $type
$fileSystemAccessRule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $fileSystemAccessRuleArgumentList
$NewAcl.SetAccessRule($fileSystemAccessRule)
$Folder | Set-Acl -AclObject $NewAcl