PowerShell、Exchange 2010 地址簿

发布于 2024-10-12 09:56:40 字数 694 浏览 3 评论 0原文

是否可以从客户端上运行的 PowerShell 脚本访问 Exchange 2010 地址簿? 我想访问地址簿、按属性搜索并处理结果。

我还没有找到任何有关 EWS 和 PowerShell 的教程。

[Reflection.Assembly]::LoadFrom("path to ews.dll")


$ExchangeService = new-object ExchangeServiceBinding

$paramName = New-Object UserConfigurationNameType
$paramName.Item = New-Object FolderIdType
$paramName.Name = "CategoryList"

$params = New-Object GetUserConfigurationType
$params.UserConfigurationName = $paramName
$params.UserConfigurationProperties = [UserConfigurationPropertyType]::ALL


$ExchangeService.UseDefaultCredentials
$ExchangeService.Url = "https://path.to.exchange/EWS/Exchange.asmx"
$ExchangeService.GetUserConfiguration($params)

It is possible to access Exchange 2010 Addressbook from a PowerShell Script which is running on a client?
I want to access the addressbook, search by properties and work with the results.

I have not found any tutorial for the EWS and PowerShell.

[Reflection.Assembly]::LoadFrom("path to ews.dll")


$ExchangeService = new-object ExchangeServiceBinding

$paramName = New-Object UserConfigurationNameType
$paramName.Item = New-Object FolderIdType
$paramName.Name = "CategoryList"

$params = New-Object GetUserConfigurationType
$params.UserConfigurationName = $paramName
$params.UserConfigurationProperties = [UserConfigurationPropertyType]::ALL


$ExchangeService.UseDefaultCredentials
$ExchangeService.Url = "https://path.to.exchange/EWS/Exchange.asmx"
$ExchangeService.GetUserConfiguration($params)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

自此以后,行同陌路 2024-10-19 09:56:40

我不了解 PowerShell,但您可以在 Exchange Management Shell (EMC) 中完成此操作。 PowerShell v2.0+ 可以运行远程会话,因此可以从客户端使用 EMC 命令。当然,他们需要一些 Exchange 权限才能做到这一点。在 Exchange 2010 中,RBAC 允许您向用户授予极小的 Exchange 权限,这很方便。如果这不是一个选项,您可以执行 LDAP 查询(这就是 Outlook 所做的),但我不确定确切的过程。


但是,如果可以选择:

1. Initiate your remote PowerShell session.  
1a. $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionURI http://FQDNofCAS/PowerShell/ -Authentication Kerberos  
1b. Import-PSSession $session

之后,请尝试以下操作之一:

1. Get-GlobalAddressList  
1b. Note the GAL you'll be using  
2. $GAL = (Get-GlobalAddressList "Default Global Address List").DistinguishedName  
2b. Replace _Default GAL_ with the output of step one.  
3. Get-GlobalAddressList $GAL | Update-GlobalAddressList  
4. Get-Recipinet -Filter {Addresslistmembership -eq $GAL}
4b. -Filter may require some tweaking to your specifics.  

注意:请参阅 http://www.msexchange.org/articles_tutorials/exchange-server-2007/management-administration/address-lists-exchange-2007-part1.html 对此有更好的解释。

--或--

1. Get-User | where($_.RecipientType -like "*Mail*"}  

注意:这将显示所有启用邮件的用户,因此它可能不完全是您要查找的内容。

I don't know about PowerShell, but you can accomplish this in Exchange Management Shell (EMC). PowerShell v2.0+ can run remote sessions, so the EMC commands can be used from your clients. Of course they'll need some Exchange rights to do this. Conveniently in Exchange 2010, RBAC allows you to give miniscule Exchange rights to your users. If this is not an option, you could do an LDAP query (that's what Outlook does) but I'm not sure of the exact procedure.


However, if it is an option:

1. Initiate your remote PowerShell session.  
1a. $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionURI http://FQDNofCAS/PowerShell/ -Authentication Kerberos  
1b. Import-PSSession $session

After that, try one of the following:

1. Get-GlobalAddressList  
1b. Note the GAL you'll be using  
2. $GAL = (Get-GlobalAddressList "Default Global Address List").DistinguishedName  
2b. Replace _Default GAL_ with the output of step one.  
3. Get-GlobalAddressList $GAL | Update-GlobalAddressList  
4. Get-Recipinet -Filter {Addresslistmembership -eq $GAL}
4b. -Filter may require some tweaking to your specifics.  

Note: See http://www.msexchange.org/articles_tutorials/exchange-server-2007/management-administration/address-lists-exchange-2007-part1.html for a better explanation of this.

--OR--

1. Get-User | where($_.RecipientType -like "*Mail*"}  

Note: This will show all Mail-Enabled users, so it might not be exactly what you're looking for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文