Benutzer-Werkzeuge

Webseiten-Werkzeuge


powershell:berechtigungenordneraendern

Dies ist eine alte Version des Dokuments!


Berechtigungen Ordner ändern

Funktion mit Angabe von Credentials und Invoke-Command

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
}

Funktion ohne Angabe von Credentials, für lokale Ausführung

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:

powershell/berechtigungenordneraendern.1426599638.txt.gz · Zuletzt geändert: 2016/04/02 00:38 (Externe Bearbeitung)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki