【发布时间】:2017-02-06 14:39:43
【问题描述】:
我尝试搜索但找不到任何东西,这并不奇怪,因为我认为我们尝试做的事情并不常见。
我有一个脚本,它根据过滤器和自定义属性属性收集 AD 用户,我们使用自定义扩展架构及其值。
我确实有一个名为 smtpHistory 的属性,其中存储了分配给用户的 SMTP 历史记录,我需要在将任何现有条目转换为小写。
我现在做的和
类似$mailHistory = $_.smtpHistory
$lowerMailHistory = $mailHistory.tolower()
# Insert all existing addresses in lowercase to the history attribute
Set-ADUser $_.SamAccountName -add @{ smtpHistory= $lowerMailHistory }
$newMail = $_.mail
# Append new default email address to smtpHistory
#Set-ADUser $_.SamAccountNAme -Add @{ smtpHistory= "SMTP:$newMail" }
从技术上讲,上述方法有效,但是当我检查 smtpHistory 属性时,我得到的是单行上的多个值,例如
smtp:test7@gmail.com smtp:test6@gmail.com
而不是像每行一个值
smtp:test7@gmail.com
smtp:test6@gmail.com
我通过用户循环的方式是通过
$usersProxyAddress | ForEach-Object { ...
由于使用 foreach($usersProxyAddress 中的 $a)会产生每个用户的 DN,因此我无法访问单个属性(可能是我的错)。
这可能是我忽略的一些愚蠢的事情,但我找不到解决问题的方法,任何指针/帮助将不胜感激。
提前致谢,丹。
【问题讨论】:
-
smtpHistory属性模式是如何定义的?是否正确定义为多值属性? -
属性被定义为多值是的。到目前为止,通过 Google 应用程序提供商导出的 CSV 文件填充属性很容易,现在我们需要从邮件属性中收集值。
标签: powershell active-directory attributes custom-attributes