2011-03-24 150 views
1

我想编写一个Powershell脚本来验证AD团队提供给我的大量服务帐户。不是我不相信他们,但我想循环每个域用户名和密码,以查看它是否登录或失败。我正在寻找一些建议,至今我的尝试失败了(请参阅文章http://tjo.me/fKtvPM)。验证服务帐户Powershell

谢谢

P.S.我无权访问AD,因此我必须尝试使用​​凭据进行登录才能测试。

回答

0

这真的很糟糕(丑陋的最小特权模型),但如果您知道所有服务帐户都可以访问特定的程序/文件,则可以尝试使用其凭据启动进程。

$cred = get-credential # however you're getting the info from AD team, pass it hear to get-credential 
start-process powershell -argumentlist "-command","exit" -cred (get-credential) 
$? # if $true, process started (and exited) successfully, else failed (either bad creds or account can't access powershell.exe 

不幸的是,因为你不能直接查询AD,我认为任何解决方案将是一个黑客攻击的一位,因为从定义你将不得不模拟登录的用户帐户。

+0

虽然有效,但并不像我希望的那样健壮。我也需要循环一大堆账户。 – ChiliYago 2011-04-07 18:16:24