简体   繁体   English

Powershell 过滤器 ADgroups 的正确方式

[英]Powershell Filter ADgroups the right way

Hi im trying to Filter AD-Groups by a string i defined in a variable:嗨,我正在尝试通过我在变量中定义的字符串过滤 AD 组:

$groupname="string"
Get-ADGroup -filter {GroupCategory -eq "security" -and Name -like ($sgroup_name+"*")}

How do i do this the right way?我该如何以正确的方式做到这一点?

String expansion doesn't work well with the -Filter parameter when passing it a script block - use a string filter instead:-Filter参数传递给脚本块时,字符串扩展不适用于-Filter参数 - 请改用字符串过滤器:

$groupname = "string"

Get-ADGroup -Filter "GroupCategory -eq 'security' -and Name -like '${groupname}*'"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM