powershell - 使用 PowerShell 使用电子邮件地址更新 AD 中的职位描述
问题描述
我目前正在尝试编写一个 powershell 脚本,该脚本将通过 CSV 文件更新 Active Directory 中各种用户的作业描述
我使用的标识符是用户的电子邮件地址而不是用户名(我认为这会更容易!)
任何人都可以提供帮助,因为我正在努力编写任何有效的有效方法!:(
解决方案
好的,假设您的 .csv 看起来像这样:
"email","jobtitle"
"user1@mydomain.com","New job description for user1"
"user2@mydomain.com","New job description for user2"
"user3@mydomain.com","New job description for user3"
然后你可以做类似的事情
Import-Module ActiveDirectory
Import-CSV -Path <PATH-TO-YOUR-CSV-FILE> | Foreach-Object {
# properties from the csv
$mail = $_.email
$title = $_.jobtitle
Get-ADUser -Filter {(mail -eq "$mail")} | Set-ADUser -Title $title
}
推荐阅读
- ios - 如何在 iOS 的 WebView(react-native-webview) 中设置自定义字体?
- python - 以正常 barmode='group' 方式绘制具有多个 y 轴的条形图
- node.js - 更新嵌套对象属性 mongoose
- jquery - 切换元素,如果第一次单击切换该 div 内的所有元素
- xamarin - MasterDetail 登录后可见
- php - simplexml_load_string():内存分配失败
- c - 在构建将使用 LoadLibrary 加载的 DLL 时,我是否需要链接依赖的二进制文件或者是否包含足够的头文件?
- html - 如何围绕文本旋转框阴影?
- php - 商店页面上单独 div 中的每个产品颜色属性
- javascript - 如何在反应中将类组件作为功能道具传递?