J'essaie de créer un utilisateur en utilisant l'objet ADSI s'il n'existe pas déjà. Voici les résultats étranges que j'obtiens[ADSI] :: Exists lève une exception au lieu de renvoyer False
#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"
La dernière ligne n'a aucun sens pour moi. Pourquoi lancer une exception quand je spécifie que je cherche spécifiquement un utilisateur, mais quand je ne spécifie pas que je veux un utilisateur cela fonctionne très bien? Cela me semble complètement inintéressant. Qu'est-ce que je rate?