How can I use PowerShell to find AD site options like +IS_INTER_SITE_AUTO_TOPOLOGY_DISABLED
in PowerShell? I've been playing around with the following command, but can't get it to spit out anything useful.
Get-ADObject -Filter 'objectClass -eq "site"' -Searchbase (Get-ADRootDSE).ConfigurationNamingContext` -Properties options
Edit #3: Updating reference documentation.
Edit #2: Editing one more time because I wrote something in PS to do exactly what you are trying to do. It's at the bottom.
I'm going to go ahead and assert that there's no Powershell Friendly (tm) way of doing it at present. But of course you could still use Powershell to make the LDAP query necessary to see these options if you really wanted to. Check out the
options
attribute of theNTDS Settings
object of each server that is associated to an AD site:That is the exact attribute, which is a bitmask, that repadmin.exe works on. Repadmin.exe contains a friendly bitmask translator in its code. As does the ADSIEdit MMC snap-in. However, you would need to recreate that bitmask translator in Powershell.
For instance,
Repadmin /options <DC> [{+|-} IS_GC]
is a valid command, and now we know exactly which bit on which it operates.Here is the relatively crappy MSDN documentation on theoptions
attribute.Better MSDN documentation on the
options
attribute.And here is an example of searching for options using old-school matching rule operators:
Oh boy does that sound fun!
Some other values for the bitmask:
So with that you should have enough information to roll your own
Get-ADSiteOptions
Cmdlet... if you want me to write one for you I will, for a very modest fee... ;)Edit: Here is the Microsoft link, Repadmin for Experts, which details the difference between the
options
andsiteoptions
subcommands of repadmin:As for that bitmap? Is it even documented? Not sure. If you can tell me whatYou're such a showoff, MDMarra. ;)FORCE_KCC_WHISTLER_BEHAVIOR
means in an interview, I will hire you on the spot.So just to sum up, the
options
attribute on theCN=NTDS Settings
object for each domain controller corresponds to the DC-specific options, i.e.,repadmin <DC> /options
, whereas theoptions
attribute on theCN=NTDS Site Settings
object under each site corresponds torepadmin /siteoptions
.So, to finally answer your question. Getting specifically site options, not DC options:
If there are no site options set, Powershell won't return them. You could probably simplify the above code a little but that's using the parlance you started with. After way too much searching, I finally found the documentation on the site options bitmask:
So for
IS_INTER_SITE_AUTO_TOPOLOGY_DISABLED
that you gave as an example, you'd be looking for a value of0x00000010
for theoptions
attribute.And from running the Powershell snippet:
Edit #2: I wrote you something today:
And here it is in action:
The documentation mentioned by Ryan omits 2 NTDSettings Options necessary to support all combinations. Please find below those values found in
ntdsapi.h
:And
can be simplified by