简体   繁体   English

Powershell结合了lync和AD cmdlet

[英]powershell combine lync and AD cmdlets

I'm trying to write a single command in PS which lets me the AD account for all lync enabled users by samaccountname 我正在尝试在PS中编写一个命令,该命令可以让我通过samaccountname为所有启用了lync的用户使用AD帐户

I tried this: 我尝试了这个:

get-csuser | where {$_.Enabled -eq $True -and $_.SipAddress -ne $null} | foreach-object {get-aduser -filter {samaccountname -eq $_.samaccountname}}

This however doesn't work 但是这不起作用

I know I can do this with a simple script, but the reason I need to do this on the command line is that I am using C# to invoke the above, and I don't want to create 2 powershell objects (for performance reason), so I would like to run the entire command in one powershell unit. 我知道我可以使用一个简单的脚本来执行此操作,但是我需要在命令行上执行此操作的原因是我正在使用C#来调用上述命令,并且我不想创建2个powershell对象(出于性能原因) ,因此我想在一个powershell单元中运行整个命令。

Any ideas how should I fix the above script? 有什么想法我应该如何解决上述脚本?

Thanks in advance 提前致谢

Right, here I am answering my own question again (rather than deleting my post, incase it helps someone in the future). 是的,我在这里再次回答自己的问题(而不是删除我的帖子,以免将来对某人有所帮助)。

It seems the property name is case-sensitive, so I need to replace: 似乎属性名称区分大小写,因此我需要替换:

$_.samaacountname $ _。samaacountname

with

$_.SamAccountName $ _。SamAccountName

works like a charm after that 之后就像魅力一样

get-csuser | get-csuser | select samaccountname 选择samaccountname

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

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