Skip to content

Avoid Get-Acl/Set-Acl cmdlets in PowerShell as they have inappropriate permissions testing. - #1692

Merged
DanGough merged 4 commits into
mainfrom
setAdtItemPermission
Sep 2, 2025
Merged

DanGough merged 4 commits into
mainfrom
setAdtItemPermission

Conversation

@mjr4077au

Copy link
Copy Markdown
Member

Fixes #1691.

@mjr4077au mjr4077au added this to the 4.1.4 milestone Sep 2, 2025
@mjr4077au
mjr4077au requested a review from DanGough September 2, 2025 03:25
@mjr4077au mjr4077au self-assigned this Sep 2, 2025
@mjr4077au mjr4077au added the Type: Issue / Bug Something isn't working as expected label Sep 2, 2025
@mjr4077au
mjr4077au force-pushed the setAdtItemPermission branch from 7ddb886 to 4baca77 Compare September 2, 2025 04:21
@neo42JBR

neo42JBR commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

FYI: The security methods of DirectoryInfo and FileInfo have been moved into a different namespace in powershell core and are now extension methods in FileSystemAclExtensions.

@mjr4077au

Copy link
Copy Markdown
Member Author

@neo42JBR this should still be fine as we do the exact same setup in our C# code and this dual-compiles as net472 and net8.0-windows:

FileSecurity fileSecurity = path.GetAccessControl(AccessControlSections.Access);
fileSecurity.AddAccessRule(fileSystemAccessRule);
path.SetAccessControl(fileSecurity);

@mjr4077au

Copy link
Copy Markdown
Member Author

Oh I see, it's an actual extension method which won't work in PowerShell. Onto it.

@mjr4077au

Copy link
Copy Markdown
Member Author

@neo42JBR addressed via 9edfce3. Appreciate the shout-out regarding this! 🤜🤛

@DanGough
DanGough merged commit 09cc436 into main Sep 2, 2025
2 checks passed
@DanGough
DanGough deleted the setAdtItemPermission branch September 2, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Issue / Bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] EnableInheritance / DisableInheritance parameters in Set-ADTItemPermission require admin rights

3 participants