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

[玩转系统] 批量更改特殊 Active Directory 用户的 SIP 地址

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

批量更改特殊 Active Directory 用户的 SIP 地址


许多中小型企业的客户正在使用 CTI 软件进行呼叫并将其 PC 与电话连接。在大多数情况下,软件连接到活动目录,并且它使用或可能将 SIP 属性添加到“代理地址”属性。有时这些软件会复制 UPN(用户主体名称),但通常与电子邮件地址不同。结果就是“虚假”SIP 地址。本文介绍如何将其更正为主邮件地址。如果你使用 azure ad connect 并想要登录 Skype for Business,这也可能会导致问题。

注意:仅需要 AD Powershell 模块和对 ActiveDirectory 的管理访问权限。 我必须执行此更改,因为客户想要使用 Skype for Business,但他无法使用他的电子邮件地址进行身份验证(azure AD 同步)当然启用)。

我的演示只有三个生成的用户,但这也应该适用于更大的环境。

[玩转系统] 批量更改特殊 Active Directory 用户的 SIP 地址

设置:3 个用户,其中两个拥有电子邮件地址并定义了不同的 SIP/SMTP 地址。看我的截图。

[玩转系统] 批量更改特殊 Active Directory 用户的 SIP 地址

正如您所看到的,有两个 SIP 地址,但它们都是错误的。您可以使用 ISE 或其他 PowerShell 编辑器来执行该脚本。

那么我的脚本在做什么?
1.搜索所有设置了电子邮件地址的用户(属性邮件)
2.将所有这些用户的 SIP 地址导出到 CSV 文件中
3.搜索所有 SIP 地址并删除所有 SIP 地址
4.添加与电子邮件属性相同的 SIP 地址
5。将新的 SIP 地址导出到另一个文件

Import-Module ActiveDirectory
#OU Path where users with false SIP addresses are stored (distinguishedName)
$ou = "OU=DEMO-USERS,OU=DEMO,DC=demo,DC=it-koehler,DC=com"
#export path for csv before editing
$exppath = "C:\temp" 
$exportpath = "$exppath\sip-orig.csv"
#export path after correction of sip address
$exportpathedit = "$exppath\sip-edited.csv"
# searches and writes all users into varialbe users where E-Mail attribute is not empty and contains @demo
$users = (Get-ADUser -Filter * -Properties * -SearchBase "$ou" | Where-Object {$_.mail -ne $null} | Sort-Object mail)
# NOTE: if you want to filter your mail addresses you can replace the line above with the following line and replace also "@demo"
#$users = (Get-ADUser -Filter * -Properties * -SearchBase "$ou" | Where-Object {($_.mail -ne $null) -and ($_.mail -like "*@demo*")} | Sort-Object mail) 
#export to csv before editing anything 
# https://www.blackforce.co.uk/2016/09/23/export-list-users-ad-proxy-addresses
$users | Select-Object Name, @{L = "ProxyAddresses"; E = { $_.ProxyAddresses -join ";"}} | Export-Csv -Path $exportpath -Delimiter ";" -NoTypeInformation
#the following code is done for every user found in $users 
foreach($user in $users){
  #getting emailaddress  
  $email = (($user).mail)
  #getting all SIP addresses from attribute "proxyaddresses"
  $proxy = (($user).proxyAddresses) | Where-Object {$_ -like "*SIP:*"}
  Write-Host "User: $email changed"
   #remove every sip address from user (even if there are more than one)   
   foreach ($addr in $proxy){
       Set-Aduser -identity "$User" -Remove @{proxyAddresses="$addr"}
   }
    #adding one sip address from the mail attribute 
    Set-ADUser -Identity "$user" -Add @{proxyAddresses ="SIP:"+"$email"}
}
#export all SIP Addresses after editing
$users = (Get-ADUser -Filter * -Properties * -SearchBase "$ou" | Where-Object {$_.mail -ne $null} | Sort-Object mail)
$users | Select-Object Name, @{L = "ProxyAddresses"; E = { $_.ProxyAddresses -join ";"}} | Export-Csv -Path $exportpathedit -Delimiter ";" -NoTypeInformation

你必须改变两条路径;
第一个:$ou =“OU=DEMO-USERS,OU=DEMO,DC=demo,DC=it-koehler,DC=com”
第二个:$exppath =“C:\temp ”

文件 csv 在之前和之后应该看起来相同,但它应该包含不同的内容

[玩转系统] 批量更改特殊 Active Directory 用户的 SIP 地址

[玩转系统] 批量更改特殊 Active Directory 用户的 SIP 地址

如果您的 SIP 地址不正确,您可以使用脚本快速纠正它。在改变每个人之前要小心并尝试一些试点用户。某些 CTI 软件可能不喜欢此更改。
享受脚本的乐趣。如果您喜欢这篇文章,请点击“有用”。

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

取消回复欢迎 发表评论:

关灯