powershell - 创建多个广告组并设置电子邮件的脚本(不使用交换)
问题描述
Powershell新手在这里。我需要一个脚本来创建批量广告组并设置该组的电子邮件地址。我们不使用交换。不使用交换时,我无法找到好的示例。
$Example = get-content c:\temp\Example.txt
foreach($Example in $Example){
New-ADGroup -Name "$Example.###" -SamAccountName "$Example.###" -Email "$Example.###@Anywhere.com" -ParentContainer "OU=THERE,OU=Organization,DC=HERE,DC=NET" -GroupType "Security" -GroupScope "Global"
}
解决方案
New-AdGroup
没有参数Email
。你将不得不使用
-OtherAttributes @{mail = "$Example.###@Anywhere.com"}
PS。如果变量后面的点导致问题,你也可以像这样格式化
-OtherAttributes @{mail = ('{0}.###@Anywhere.com' -f $Example)}
推荐阅读
- git - Github 无法访问... gnutls_handshake() failed:Close notify
- java - Postgres UUID 和 Hibernate → 未找到列
- python - RDF 主题的属性
- android - 我在哪里可以找到 ObjectBox 中的 Data.mdb?
- javascript - 如何调试 Angular 错误 - 错误:未捕获(承诺中):TypeError:无法读取 null 的属性“数据”
- php - Laravel 5.8 迁移中的外键未知(MEDIUMINT?)问题
- javascript - 如何在JS中存储常用费用数据
- python - 采用 1 个参数 x 或另一个的函数
- c - 需要帮助从文件中读取并将内容存储到二维数组中
- php - 如何加快 MySQL UPDATE 查询以获得更好的每秒性能