====== Besitzer eines Ordners ändern ======
function setfilesystemowner ([string]$file, [string]$PrincipalAccount, [string]$DC, [string]$AdminAccount, [string]$Password)
{
$acl = get-acl $file
$acc = new-object System.Security.Principal.NTAccount($PrincipalAccount)
$acl.setowner($acc)
$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 setfilesystemowner ([string]$file, [string]$PrincipalAccount)
{
$acl = get-acl $file
$acc = new-object System.Security.Principal.NTAccount($PrincipalAccount)
$acl.setowner($acc)
Set-ACL $file $acl
}
Parameter:
{{changentfsownerparameter.png|}}
{{tag>[Powershell]}}