-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
Set-Owner does not work on PowerShell 6 due to referencing .NET Framework assembly APIs. .NET Core has refactored these APIs, and they no longer work in PowerShell 6 because the API is not there.
The following is a simpler Set-Owner script:
#
# IMPORTANT: Run with ELEVATION
#
# The target folder.
$folder = 'C:\Temp'
# Specify the new owner, which can be a mere username ('John.Doe'), a well-known
# security principal ('BUILTIN\Administrators'), or a UPN ('[email protected]')
$newOwner = 'BUILTIN\Administrators'
# Get the current ACL...
$acl = Get-Acl -LiteralPath $folder
# ... and assign the new owner...
$acl.SetOwner([System.Security.Principal.NTAccount] $newOwner)
# ... and set the modified ACL.
Set-Acl -LiteralPath $folder -AclObject $acl
"New owner: $((Get-Acl -LiteralPath $folder).Owner)"Metadata
Metadata
Assignees
Labels
No labels