![我需要帮助从 AD LDS 域中删除批量用户的邮件属性](https://linux22.com/image/759676/%E6%88%91%E9%9C%80%E8%A6%81%E5%B8%AE%E5%8A%A9%E4%BB%8E%20AD%20LDS%20%E5%9F%9F%E4%B8%AD%E5%88%A0%E9%99%A4%E6%89%B9%E9%87%8F%E7%94%A8%E6%88%B7%E7%9A%84%E9%82%AE%E4%BB%B6%E5%B1%9E%E6%80%A7.png)
这里的脚本哪里出错了?它没有给出任何错误。但它没有删除
$cred= get-credential "s2\svcfimadamadmapeu"
$CSV= Get-content '.\input.csv'
function UpdateADAMUserDetails
{
param(
[string] $ADCN,
[string] $mail
)
$domaininfo = new-object DirectoryServices.DirectoryEntry("LDAP://b-004.ldap.unilever.com/DC=D1,DC=MS,DC=Unilever,DC=COM",$ADAMCredential.GetNetworkCredential().UserName,$ADAMCredential.GetNetworkCredential().Password)
$ADAMsearcher = new-object DirectoryServices.DirectorySearcher($domaininfo)
$ADAMsearcher.filter = “(&(ObjectClass=userProxyFull)(CN=$ADCN))”
$ADAMsearcher.CacheResults = $true
$ADAMsearcher.SearchScope = 'Subtree'
$ADAMsearcher.PageSize = 1000
$ADAMUserAttributes=$ADAMsearcher.FindOne()
if ($ADAMUserAttributes)
{
$entryToUpdate = $ADAMUserAttributes.GetDirectoryEntry()
if($mail)
{
$entryToUpdate.Put("mail",$Null)
}
try
{
$entryToUpdate.SetInfo()
WriteLog "Success: removed mail in ADAM `r"
}
catch
{
WriteLog "Error: $UserID Couldn't remove mail in ADAM `r"
"Error: $UserID Couldn't remove mail in ADAM `r" | out-file ".\out.csv" -append
}
}
}