Powershell 如何获取属性';NTDS设置中的s值

Powershell 如何获取属性';NTDS设置中的s值,powershell,active-directory,attributes,Powershell,Active Directory,Attributes,我正在尝试从NTDS设置读取属性值。 *您可以通过打开Active Directory站点和服务>站点>默认首个站点名称>服务器>MyDCName>NTDS设置来使用GUI查看设置 例如,我试图读取instanceType的值。 一开始我用的是脚本 我运行了以下命令: #Get the config partition DN $Config = (Get-ADRootDSE).configurationNamingContext #Use Get-ADObject to list serve

我正在尝试从NTDS设置读取属性值。
*您可以通过打开
Active Directory站点和服务>站点>默认首个站点名称>服务器>MyDCName>NTDS设置来使用GUI查看设置

例如,我试图读取
instanceType
的值。

一开始我用的是脚本

我运行了以下命令:

#Get the config partition DN
$Config = (Get-ADRootDSE).configurationNamingContext

#Use Get-ADObject to list server objects for current forest
$Servers = Get-ADObject -Filter {ObjectClass -eq "Server"} -SearchBase "CN=Sites,$Config" -SearchScope Subtree

#Test for NTDS Settings object
$Ntdsa = Get-ADObject -Filter {ObjectClass -eq "nTDSDSA"} -SearchBase "$(($Servers).DistinguishedName)" -SearchScope Subtree
但它没有给我NTD的属性列表

我添加了另一个命令:

Get-ADReplicationAttributeMetadata -Object $Servers -Server $Servers.Name
它给了我一个小属性列表,但很多都是遗漏


你知道我怎么做吗

默认情况下,
获取ADObject
仅返回一组有限的属性值。使用
-Properties
参数指定其他属性名称:

# Specify * for all attribute values
$Ntdsa = Get-ADObject -Filter {ObjectClass -eq "nTDSDSA"} -Properties * -SearchBase "CN=Sites,$Config"
# or
# Specify a list of attribute names
$Ntdsa = Get-ADObject -Filter {ObjectClass -eq "nTDSDSA"} -Properties 'instanceType','msDS-Behavior-Version' -SearchBase "CN=Sites,$Config"

# This should now return a value
$Ntdsa.instanceType 

-Properties*
添加到最后一个
Get-ADObject
查询中,以从
nTDSDSA
对象中获取所有属性值谢谢,但为什么它不显示所有属性呢?例如,当我使用此查询时,属性
msDS NcType
不会出现,但会出现在GUI上。啊,因为它是
,所以一切都正常。谢谢@E235是的,这可能是因为从未在对象上设置属性。您可以从模式中检索所有可能包含的属性(GUI就是这样做的),但您可能不需要这样做