How can I fix a PowerShell SetAccessControl unauthorized operation error?

0
1
Asked By MellowTide47 On

I'm not very experienced with PowerShell, so please bear with me. I used a script to modify some video game files, and it worked with an older version, but the newer version now fails every time with: "Exception calling "SetAccessControl" with "1" argument(s): "Attempted to perform an unauthorized operation." I launch PowerShell as administrator and run the script from a .ps1 file. What permissions or settings should I check to fix this?

2 Answers

Answered By OrbitLime84 On

The directory may contain an explicit Deny rule for writing or deleting files. Deny permissions override Allow permissions, including permissions inherited by administrators. If the game is installed under a protected location such as Program Files, TrustedInstaller or other custom rules may also block SetAccessControl. Inspect the folder’s Advanced Security settings, check its owner and inherited permissions, and avoid changing permissions on the parent system folder when possible.

MellowTide47 -

My game was installed in a separate directory rather than directly under Program Files. Giving my account permission on that whole game directory resolved it.

Answered By CedarFox29 On

Check the owner and access control list on the target directory. Being an administrator does not automatically mean your account has permission to change every file. Granting your user account full control on the game directory fixed the problem in this case.

MellowTide47 -

That solved it for me. I gave my user account full control over the game directory, and the script started working again.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.