Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Create folder and assign Security permission using power shell.

$
0
0

Hi,

I am getting an error at line 22, char 17. I was able to execute this once succesfully, not sure what changed in between..Can any one find what the error is.

$loc = Read-Host 'Where do you want to create the folder? '
$fol = Read-Host 'Enter the name of the folder to be created? '
New-Item -ItemType directory -Path $loc\$fol

$t = Get-Acl $loc

$computer = Read-Host 'Enter the full computer name'

$username = Read-Host 'user'

$objUser = New-Object System.Security.Principal.NTAccount("$computer\$user")

$Rights = [system.security.accesscontrol.filesystemrights]"Read, Write"

$Type = [system.security.accesscontrol.accesscontroltype]::Allow

$InheritanceFlag = [System.Security.AccessControl.InheritanceFlags]::ObjectInherit 
$PropagationFlag = [System.Security.AccessControl.PropagationFlags]::None 

$objACE = New-Object System.Security.AccessControl.FileSystemAccessRule($objUser, $Rights, $InheritanceFlag, $PropagationFlag, $Type) 

$t.addAccessRule($objACE)

Set-Acl $loc\$fol $t


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>