0

我正在阅读一份工作文件,其中涉及一堆职位头衔,但我不知道这些人到底是谁,我只知道他们的职位头衔。

我知道此信息可在全球通讯录中找到,但我不知道如何输入职位(我猜是位置)并取回实际人员的姓名和联系信息。

是否可以使用 powershell “几乎”在 GAL 中查找联系人,使用职位作为输入,联系人作为输出?

o365 当然...

4

1 回答 1

0

至于...

是否可以使用 powershell “几乎”在 GAL 中查找联系人,使用职位作为输入,联系人作为输出?

...简单的答案,是的。您只需为其编写代码,就像这是本地 Exchange 一样,当然也可以通过 PSRemote 会话使用 Exchange Online cmdlet。

连接到 EXO 我们是一个日常用例,并完整记录了来自 Microsoft 的方法: 连接到 Exchange Online PowerShell

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking

或者只使用来自 MS PowerSHellGallery.com 的这个脚本

https://www.powershellgallery.com/packages/Connect-O365/1.5.4/Content/Connect-O365.ps1

或者这个

https://gallery.technet.microsoft.com/office/Connect-to-Office-53f6eb07/file/221497/1/Connect-Office365Services.ps1

然而,请记住 GAL 是从 AD 填充的。因此,如果您处于混合环境中,您只需点击本地 AD 即可获得此信息。

您有一个用于用户搜索 AD 和 EXP/EXO 的内置 cmdlet:

Get-Command -Name '*adaccount*' | Format-Table -AutoSize

CommandType Name                                            Version Source         
----------- ----                                            ------- ------         
Alias       Set-ADAccountPasswordHash                       3.4     DSInternals    
Cmdlet      Clear-ADAccountExpiration                       1.0.1.0 ActiveDirectory
Cmdlet      Disable-ADAccount                               1.0.1.0 ActiveDirectory
Cmdlet      Enable-ADAccount                                1.0.1.0 ActiveDirectory
Cmdlet      Get-ADAccountAuthorizationGroup                 1.0.1.0 ActiveDirectory
Cmdlet      Get-ADAccountResultantPasswordReplicationPolicy 1.0.1.0 ActiveDirectory
Cmdlet      Search-ADAccount                                1.0.1.0 ActiveDirectory
Cmdlet      Set-ADAccountAuthenticationPolicySilo           1.0.1.0 ActiveDirectory
Cmdlet      Set-ADAccountControl                            1.0.1.0 ActiveDirectory
Cmdlet      Set-ADAccountExpiration                         1.0.1.0 ActiveDirectory
Cmdlet      Set-ADAccountPassword                           1.0.1.0 ActiveDirectory
Cmdlet      Unlock-ADAccount                                1.0.1.0 ActiveDirectory



# get function / cmdlet details
(Get-Command -Name Search-ADAccount).Parameters.Keys
Get-help -Name Search-ADAccount -Full
Get-help -Name Search-ADAccount -Online
Get-help -Name Search-ADAccount -Examples

Search-ADAccount -AccountDisabled | FT Name,ObjectClass -A  
Search-ADAccount -AccountDisabled -UsersOnly | FT Name,ObjectClass -A   
Search-ADAccount -AccountExpired | FT Name,ObjectClass -A   
Search-ADAccount -AccountExpiring -TimeSpan 6.00:00:00 | FT Name,ObjectClass -A 
Search-ADAccount -AccountInactive -TimeSpan 90.00:00:00 | FT Name,ObjectClass -A    
Search-ADAccount -PasswordExpired | FT Name,ObjectClass -A  
Search-ADAccount -PasswordNeverExpires | FT Name,ObjectClass -A 
Search-ADAccount -LockedOut | FT Name,ObjectClass -A    
Search-ADAccount -AccountDisabled -ComputersOnly | FT Name,ObjectClass -A   
Search-ADAccount -AccountExpiring -DateTime "3/18/2009" | FT Name,ObjectClass -A    
Search-AdAccount -AccountDisabled -SearchBase "DC=AppNC" -Server "FABRIKAM-SRV1:60000"  

# Or just use
(Get-Command -Name Get-ADUser).Parameters.Keys
Get-help -Name Get-ADUser -Full
Get-help -Name Get-ADUser -Online
Get-help -Name Get-ADUser -Examples 


# If you are really wanting to do this using EXP/EXO, then it provide a cmdlet to help
Get-ADObject -ldapfilter "(&(objectClass=contact)(objectCategory=person)(!showinAddressBook=*))" -properties *

您也可以使用 ADAC 为您编写此代码,只需单击步骤并保存代码以根据需要进行修改。请遵循这些说明。

Active Directory 管理中心增强功能简介(100 级)

使用 Active Directory 管理中心学习 PowerShell(PowerShell 历史查看器)

循序渐进:在 Windows Server 2012 R2 中使用 PowerShell History Viewer

在 Windows Server 2012 中使用 Active Directory 管理中心创建 PowerShell 命令

于 2019-05-19T05:57:48.957 回答