PowerShell - NTFS Permissions

Опубликовано: 03 Август 2021
на канале: Mr Automation
870
14

(How to set permissions on registry, even when you dont have access)
In this video I demonstrate 2 scenario's for setting registry permissions with powershell, the first scenario is a very simple one, the second example is about a user who lost access to the registry key and we need to restore the permissions and ownership.
Make sure you download setacl.exe (64 bits) and place it in the c:\Windows\system32 folder.

*powershell
*learn powershell
*automation
*learn automation
*windows
*windows powershell
*automatic installations
*set registry permissions with powershell
*take ownership of registry keys
*change permissions on registry with powershell

Code:

Simple script

$subkey = "SOFTWARE\mark\wrong"
$good = get-acl "HKLM:\SOFTWARE\mark\good"
$pathwrong = "HKLM:\$subkey"
$newacl = get-acl -Path $pathwrong
$newacl.SetSecurityDescriptorSddlForm($good.Sddl)
set-acl -path $pathwrong -AclObject $newacl


Script when no access (you need to downloads setacl.exe!)

$subkey = "SOFTWARE\mark\wrong"
$owner = "Administrators"

SetACL.exe -on "HKEY_LOCAL_MACHINE\$subkey" -ot reg -actn setowner -ownr "n:$owner" -rec Yes
SetACL.exe -on "HKEY_LOCAL_MACHINE\$subkey" -ot reg -actn ace -ace "n:$owner;p:full" -rec Yes

$good = get-acl "HKLM:\SOFTWARE\mark\good"
$pathwrong = "HKLM:\SOFTWARE\mark\wrong\"

$newacl = get-acl -Path $pathwrong
#here we need to check the owner
$newacl.SetSecurityDescriptorSddlForm($good.Sddl)
set-acl -path $pathwrong -AclObject $newacl


Смотрите видео PowerShell - NTFS Permissions онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Mr Automation 03 Август 2021. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 870 раз и оно понравилось 14 посетителям.