Alan's Blog

"Yeah. I wrote a script that will do that."

Menu
  • About My Blog
Menu

Get Security Set on AD Object

Posted on October 2, 2020October 2, 2020 by Alan

It’s been a while, gentle reader, since my last post. It isn’t that I haven’t been writing code, but rather that much of what I write is for internal use only. Recently I was asked to write a PowerShell script to show the advanced security for any AD object, without relying on the ActiveDirectory module. The challenge with enumerating the security of an AD object is that you have to do a lookup of the both the IdentityReference – the user or group with the delegated permission, plus a lookup of the Active Directory rights (which appear as GUIDs) from the the AD Schema. To make things, fun, there are “Extended Rights” in a different location from the ordinary list of rights delegated.

The natural impulse is to create a hashtable of all the GUID to rights names, but this can take an insufferable amount of time. Instead, I am looking them up as encountered. I found Convert-ADACL,  written by Nathan Linley in 2012, and heavily modified it to form the lookup function of the script. When you view the code, you will see that there are two hashtables, one for the Schema GUID to name mapping, and another for SID to AD object name mapping. Each time a GUID or SID is looked up it it put into the proper hashtable to speed up subsequent lookups. I have pre-populated some values in the GUID hashtable, and in my production environment I have also pre-populated some known broken SIDs.

The result of this challenge is Get-ADobjPermissions.ps1. The script runs with reasonable speed, and takes a distinguishedName as input. This is because it was written to be called from another program, and because it is easy enough to get this information from AD for any object. When I tried dressing this up to take alternate inputs, it just got ugly. This works in a multi-domain forest, and is quicker than looking at the advanced security tab in ADUC.

Script Text

Leave a Reply

You must be logged in to post a comment.

Search

Please Note

All the scripts are saved as .txt files. Newer files have a “View Script” button which will let you save or open a script in notepad. For earlier posts, the easiest way to download with IE is to right click on the link and use “Save Target As”. Rename file from Name_ext.txt to Name.ext.

To see a full post after searching, please click on the title.

PowerShell Scripts were written with version 3 or later.

https connections are supported.

All new users accounts must be approved, as are comments. Please be patient.  If you find a post error or a script which doesn’t work as expected, I appreciate being notified.  My email is my first name at the domain name, and you are welcome to contact me that way.

Tags

1E ACLS Active Directory ActiveDirectory ADSI Advanced Functions Audit Change Administrator Password COMObject Computer Groups DateTime Desktop DNS Excel FileScriptingObject Forms General GPO GPS Group Policy Hacks ISE Lockout logons NAV740 Nessus OU OU permissions Outlook Pick Folder Power PowerShell Powershell Scriptlets RDP SCCM schedule reboot Scripting Security Shell.Application user information VBA Windows Update WMI WordPress WPF

Categories

akaplan.com

  • Back to Home Page

Archives

Scripting Sites

  • A Big Pile of Small Things
  • Adam, the Automator
  • Art of the DBA
  • Ashley McGlone
  • Boe Prox
  • Carlo Mancini
  • DexterPOSH
  • Doug Finke
  • Jaap Brasser's Blog
  • JeffOps The Scripting Dutchman
  • Jonathan Medd's Blog
  • Keith Hill's Blog
  • LazyWinAdmin
  • Nana Lakshmanan
  • PowerShell Magazine
  • PowerShell Team Blog
  • PowerShell.org
  • PwrShell.net
  • Richard Siddaway's Blog
  • Ryan Yates' Blog
  • Skatterbrainz
  • The Lonely Administrator

SQL Site

  • Art of the DBA

Meta

  • Register
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
©2025 Alan's Blog | Theme by SuperbThemes

Terms and Conditions - Privacy Policy