====== Berechtigungen Ordner ändern ======
function setfilesystemrights ([string]$file, [string]$PrincipalAccount, [int]$FileSystemrights, [string]$InheritFlags, [string]$Propagationflags, [string]$Policy, [string]$DC, [string]$AdminAccount, [string]$Password)
{
$acl = get-acl $file
$acenew = new-object System.Security.AccessControl.filesystemaccessrule($PrincipalAccount,$FileSystemrights,$Inheritflags,$Propagationflags,$Policy)
$acl.addaccessrule($acenew)
$PW = ConvertTo-Securestring $Password -AsPlainText -force
$Credential = New-Object System.Management.Automation.PSCredential($AdminAccount,$PW)
$Session = New-PSSession -ComputerName $DC -Credential $Credential
Invoke-Command -Session $Session -ScriptBlock {param ($a1,$a2) Set-ACL $a1 $a2} -ArgumentList $file,$acl
Remove-PSSession $Session
}
function setfilesystemrights ([string]$file, [string]$PrincipalAccount, [int]$FileSystemrights, [string]$InheritFlags, [string]$Propagationflags, [string]$Policy)
{
$acl = get-acl $file
$acenew = new-object System.Security.AccessControl.filesystemaccessrule($PrincipalAccount,$FileSystemrights,$Inheritflags,$Propagationflags,$Policy)
$acl.addaccessrule($acenew)
Set-ACL $file $acl
}
Parameterübersicht:
{{changentfsrightparameter.png|}}
{{tag>[Powershell]}}