当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 获取 Active Directory 中所有已配置的委派(Outlook 委派)

作者:精品下载站 日期:2024-12-14 07:11:28 浏览:15 分类:玩电脑

获取 Active Directory 中所有已配置的委派(Outlook 委派)


获取 Active Directory 中所有已配置的委派(Outlook 委派)

在迁移或其他更改之前,了解哪些邮箱是所谓的替代邮箱总是很有趣的。要记住用户可以将其放在哪里:

[玩转系统] 获取 Active Directory 中所有已配置的委派(Outlook 委派)

此信息也会写入 AD 属性中,因此可以通过 Powershell 读取(最简单的方法是在 ISE 中的域控制器上或直接使用 Powershell)。
在较新的服务器中,ActiveDirectory cmdlet 会自动导入(否则,请在运行脚本之前启动“导入模块 ActiveDirectory”)。

Get-ADObject -Filter * -Properties * -SearchBase "OU=DEMO,DC=demo02,DC=it-koehler,DC=com" | Where-Object {$_.publicDelegates -ne $null} | Select-Object DisplayName,userPrincipalName,mail,publicDelegates | Sort-Object DisplayName | ft -AutoSize -Wrap

[玩转系统] 获取 Active Directory 中所有已配置的委派(Outlook 委派)

在属性“publicDelegates”中,设置了委托(因此也可以读取)。好吧,对于第一个概述来说,输出已经不太糟糕了。
我的目标是让它的格式更加美观。

这就是我设计这个脚本的原因:

#distinguished name of the ou 
$distname = "OU=DEMO,DC=demo02,DC=it-koehler,DC=com"
$length = $distname.Length
$pd = (Get-ADObject -Filter * -Properties * -SearchBase "$distname" | Where-Object {$_.publicDelegates -ne $null}) 

#listview with distinguished name
Write-Host "##### Listview #####"
Write-Host " "
foreach ($delegates in $pd){
$ident = $delegates.DistinguishedName
$DisplayName = $delegates.DisplayName
$perm = @(Get-ADObject -Identity "$ident" -Properties *  | Select-Object publicDelegates -ExpandProperty publicDelegates | Out-String)
$perm = $perm
Write-Host "Get user delegation for"
Write-Host "User:" $DisplayName
Write-Host $perm
}


#tableoverview
Write-Host "##### Tableview #####"

foreach ($delegates in $pd){

$ident = $delegates.DistinguishedName
$DisplayName = $delegates.DisplayName
$perm = @(Get-ADObject -Identity "$ident" -Properties * | Select-Object SamAccountName,Mail,@{n='Delegations';e={$_.publicDelegates-replace '^CN=|,.*$'}} | Sort-Object SamAccountName)
$perm | ft -AutoSize -Wrap
}
pause

该脚本不包括大型查询和错误处理。

我期待一些建议。

玩得开心。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯