【发布时间】:2018-12-19 18:02:40
【问题描述】:
创建一个脚本来检查 csv 文件中的用户列表是否在特定的 AD 组中
Import-Module ActiveDirectory
$userscsv = Import-Csv C:\User-list.csv
$group = "testgroup"
$members = Get-ADGroupMember -Identity $group -Recursive | Select -ExpandProperty Name
ForEach ($user in $userscsv) {
If ($members -contains $user) {
Write-Host "$user exists in the group"
} Else {
Write-Host "$user does not exists in the group"
}}
在我的 csv 文件中,我有 A1 A2 A# 等中的名称,我得到以下格式:
@{Johnny Walker=Alex Hood} does not exists in the group
【问题讨论】:
标签: powershell import-csv