Passing string in Get-ADUser filter parameter causes error - property not found in pscustomobject

后端 未结 3 1988
梦如初夏
梦如初夏 2020-11-28 17:08

I\'m trying to create a new Active Directory user, but first I verify that the user doesn\'t exist already with Get-ADUser. I import the user data from our HR d

3条回答
  •  被撕碎了的回忆
    2020-11-28 17:31

    • Never use a script block ({ ... }) as the -Filter argument - the -Filter parameter's type is [string] - construct your filter as a string.

      • BenH's answer shows how to do that.
    • While seemingly convenient, using a script block only works in very limited scenarios and causes confusion when it doesn't work - such as when involving property access, as in this case.

    For more information, see this answer of mine.

提交回复
热议问题