密码更改通知问题排除了OU powershell



我们正在使用一个好的脚本,我们希望将其扩展到搜索除一个OU之外的所有用户。我该怎么做?

提前感谢您的帮助!

密码更改通知

如何插入此代码?

Get-ADOrganizationalUnit -filter * -SearchBase 'OU=test,DC=test,DC=com' | foreach {
if($_.distinguishedname -ne "OU=not,OU=that,OU=orgUnit,OU=test,DC=test,DC=com"){
$users=Get-ADUser -filter * -searchbase $_.distinguishedname -ResultPageSize 2000 -resultSetSize 500 -searchscope Onelevel | where-object enabled -eq true 
$total=($users | measure-object).count
New-Object psobject -Property @{
OU=$_.Name;
A=$Total
}
}
}

在您链接到的文件的第132行,您会发现实际为用户查询Active Directory的语句:

$users = get-aduser -filter {(Enabled -eq $true) -and (PasswordNeverExpires -eq $false)} -properties Name, PasswordNeverExpires, PasswordExpired, PasswordLastSet, EmailAddress | where { $_.passwordexpired -eq $false }

在下一行添加以下语句:

$users = $users |Where-Object distinguishedname -notlike "*,OU=not,OU=that,OU=orgUnit,OU=test,DC=test,DC=com"

并将脚本的其余部分保留为

最新更新