如果 ADSI 对象尚不存在,我正在尝试使用它创建用户。这是我得到的奇怪结果
#Check a user that I know exists
[ADSI]::Exists("WinNT://localhost/micah,user") #True
#Check a group that I know exists
[ADSI]::Exists("WinNT://localhost/administrators,group") #True
#Check a group that DOESN'T exist
[ADSI]::Exists("WinNT://localhost/whoops,group") #False
#Check a user that DOESN'T exist (NOT specifying that the obect is a user)
[ADSI]::Exists("WinNT://localhost/test") #False (This works fine)
#Check a user that DOESN'T exist (specifying that the obect IS a user)
[ADSI]::Exists("WinNT://localhost/test,user")
#Throws exception "The user name could not be found"
最后一行对我来说毫无意义。为什么当我指定我专门寻找用户时它会抛出异常,但是当我不指定我想要一个用户时它工作得很好?这对我来说似乎完全不直观。我错过了什么?