Benutzer-Werkzeuge

Webseiten-Werkzeuge


powershell:besitzerordneraendern

Dies ist eine alte Version des Dokuments!


Besitzer eines Ordners ändern

Funktion mit Übergabe von Credentials und Invoke-Command

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
}

Funktion ohne Übergabe von Credentials

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:

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

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki