【问题标题】:Return Only different values for property仅返回不同的属性值
【发布时间】:2013-11-21 15:43:48
【问题描述】:

我希望有人可以帮助我,我希望这很容易。我希望在我的 AD 中为用户返回某个属性,但只有该属性的不同值。我已经把我开始的命令放在下面,但是这个命令为每个用户返回属性,我只希望它一次返回不同的业务单位,我不想看到同一个业务单位的多个条目。也许有一个“哪里选项”来说明财产的价值在哪里不同?我希望我有道理,如果没有,请继续询问任何其他信息。提前致谢,感谢您的帮助。

get-aduser -filter * -searchbase $ou -Properties businessunit | select businessunit | sort businessunit | Out-GridView

感谢malexander,Groub-Object 正是我所需要的,以前从未使用过! :-) 这是我的工作命令

get-aduser -filter * -searchbase $ou -Properties businessunit | Group-Object -Property businessunit | Select Name | Sort Name

【问题讨论】:

    标签: powershell


    【解决方案1】:

    查看Group-Object cmdlet。我相信它会完全按照您的要求进行。我以前用它来拉唯一性。

    $test= @(1,1,1,2,2,2,3,3,3,3)
    
    $test | Group-Object | % {write-host $_.name}
    

    【讨论】:

    • 非常感谢,效果很好。还有一件事,有没有办法排除某个业务部门的出现?我们有一些空白,我不想看到空白。我知道,我知道,我一直在努力 ;-)
    • 没关系,我找到了,我修改了过滤器,我的命令现在看起来像这样! woot woot get-aduser -filter {businessunit -like "*"} -searchbase $ou -Properties businessunit | Group-Object -Property businessunit |选择姓名 |排序名称
    猜你喜欢
    • 2020-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多