How to use a variable in an AD filter string?

后端 未结 1 1821
长情又很酷
长情又很酷 2021-01-26 02:38

I have following powershell script to get LDAP properties. I would like to pass the BadgeID as variable instead of hard coding it. The LDAP query is working with hard-coded Badg

相关标签:
1条回答
  • 2021-01-26 02:55

    Reverse the quotes of your filter expression:

    Get-ADUser -Filter "BadgeID -like '*$BadgeID*'" ...
    

    Variables are expanded in double-quoted strings, but not in single-quoted strings.

    0 讨论(0)
提交回复
热议问题