Hiding Errors When Using Get-ADGroup

后端 未结 4 1940
梦如初夏
梦如初夏 2020-12-10 04:16

I\'m working on a script that will build a new group if it doesn\'t exist. I\'m using Get-ADGroup to make sure the group doesn\'t exist using the following command:

4条回答
  •  粉色の甜心
    2020-12-10 04:29

    I realize this is old, but I also had this problem and solved it like this:

    If (Get-ADObject -Filter {objectClass -eq "Group -and samAccountName -eq "groupname"}) { //do stuff// }

提交回复
热议问题