我想验证我的标准用户是否在AD中拥有管理员帐户。
例如,Smith的samaccountname,Joe是SmithJ。我想检查他在AD中是否有ADMSmithJ
$samaccountname = Read-Host "Please type the samaccountname"
$AdUser = get-aduser $samaccountname -Properties samaccountname
Try { get-aduser "adm"$samaccountname? -Properties samaccountname
}catch{ write-host "the user $samaccountname doesnt have a priviledge (Adm) Account."
}
1条答案
按热度按时间j2cgzkjk1#
你可以这样做,而不是
try
/catch
,我个人会过滤一个用户有Name
或SamAccountName
: