創建組名為TestGroup組,然后把用戶加入這個組;也可以在AD中手動創建組
1. 使用Powershell創建組
New-ADGroup -Name TestGroup -GroupCategory Security -GroupScope Global
2. 把需要加入組中下信息導出后者是整理出來,檢驗AD數據文件內容
Import-Csv C:\1\us.csv | ForEach-Object { Try {[array]$list += Get-ADUser -Identity $_.user} Catch { $_.Exception } }
3. 查看,可以省略
$list
4. 根據表格信息把用戶添加到組中
Add-ADGroupMember -Identity 'testfujun' -Members $list