Anyone familar with Powershell and Changing Ownership of registry keys?
I know, that i need to use setakeownershipprivilege
But somehow my scripts work when running it "manually" via ISE.
When running via PSADT i get an access violation / denied..
a
Aaron Parker
04/28/2025, 10:16 PM
I have a function to do this in my Windows Enterprise Defaults package. Typically works when running as SYSTEM not as Administrator
m
Marco Zimmermann
04/29/2025, 6:26 AM
hmm running MDT as local admin.
Moved the exact same script to BIS-F Preparation (also local admin).. works.
Seems a PSADT related thing.. However running it via bisf is fine for me.
👍🏻 1
a
Aaron Parker
04/29/2025, 6:34 AM
Interesting. I see different behaviour locally as SYSTEM and via Packer
j
Jeremy Saunders
04/29/2025, 11:36 AM
You need to use both the "SeTakeOwnershipPrivilege" and "SeRestorePrivilege" privileges to take ownership of registry keys. PSADT may not execute the process elevated "as administrator". BIS-F and MDT will. But as Aaron says, the SYSTEM account will always have permissions to make the change. So you can use a short life Scheduled Task to quickly do that if really needed.
m
Marco Zimmermann
04/29/2025, 2:22 PM
scheduled task was also my first idea 🙂 TY, will try that