NTFSSecurity module - UnauthorizedAccessException when trying to add access

Use this forum to ask questions after your subscription maintenance expires or before you buy. Need information on licensing or pricing? Questions about a trial version? This is the right place for you. No scripting questions, please.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
This topic is 7 years old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
RyanL83
Posts: 4
Last visit: Fri Jul 29, 2022 8:21 am

NTFSSecurity module - UnauthorizedAccessException when trying to add access

Post by RyanL83 »

Product, version and build: PowerShell Studio 2015 4.2.99
32 or 64 bit version of product: 64 bit
Operating system: Windows 7 Enterprise
32 or 64 bit OS: 64

To start, I should mention that I have a license for PowerShell Studio 2012. However, I was getting a different error message on the same portion of this script, which I will post about in a seperate forum. However, that error prompted me to try the 2015 trial, as I thought that using PowerShell v4 might help, which it sort of did.

Basically, I am trying to use the NTFSSecurity module to make some permissions changes to a folder. I will need to add a group and 2 remove 2 other ACL entries. I have tested the script in the PowerShell ISE, and it works fine. However, when I try the exact same code in PowerShell Studio, I get an UnauthorizedAccessException. Is there anything I can do to troubleshoot/get this working?

The code looks like this:

Import-Module "$Source\assets\powershell\NTFSSecurity"

Disable-NTFSAccessInheritance -Path $Dest

Add-NTFSAccess -Path $Dest -AccessRights FullControl -Account $GroupName
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 20
Been upvoted: 37 times

Re: NTFSSecurity module - UnauthorizedAccessException when trying to add access

Post by Alexander Riedel »

The ISE usually runs elevated. In PowerShell Studio there is a button on the ribbon to run your script elevated.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 20
Been upvoted: 37 times

Re: NTFSSecurity module - UnauthorizedAccessException when trying to add access

Post by Alexander Riedel »

Just out of curiosity, where did you obtain a 2015 trial and why did you not try the latest version (2017)?
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
RyanL83
Posts: 4
Last visit: Fri Jul 29, 2022 8:21 am

Re: NTFSSecurity module - UnauthorizedAccessException when trying to add access

Post by RyanL83 »

Double checked, ISE is not running elevated.

I updated my registered version of Studio 2012 and now I am getting the same error in that version.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 20
Been upvoted: 37 times

Re: NTFSSecurity module - UnauthorizedAccessException when trying to add access

Post by Alexander Riedel »

I sincerely doubt (albeit did not verify) that you can change a folders access permission without elevation. Even in Windows 7 you would have to have UAC completely disabled.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
RyanL83
Posts: 4
Last visit: Fri Jul 29, 2022 8:21 am

Re: NTFSSecurity module - UnauthorizedAccessException when trying to add access

Post by RyanL83 »

It looks like it is possible as long as you have the appropriate permissions or are the owner of the folder. Because the script creates the folder as well, the user who will be setting the permissions is also the owner. Is there a way that I can post verification that it works as described?
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 20
Been upvoted: 37 times

Re: NTFSSecurity module - UnauthorizedAccessException when trying to add access

Post by Alexander Riedel »

"Is there a way that I can post verification that it works as described?" I am not sure what that means. Can you please elaborate?
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 7 years old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.