【发布时间】:2013-11-23 02:54:06
【问题描述】:
我目前使用此脚本从 AD 获取用户的 SID。并不是说每次我需要一个 SID 时,我都必须打开脚本并输入个人用户名,当我有 100 个人要做时,这可能会令人沮丧。当前脚本如下:
$name = "username"
(New-Object System.Security.Principal.NTAccount($name)).Translate([System.Security.Principal.SecurityIdentifier]).Value
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
有没有一种方法可以让我使用相同的脚本,但将 AD 用户名放在一个文本文件中,然后将它们拉入 powershell 并让输出像这样我得到用户名和 SID。最好是 CSV 格式?
干杯,
【问题讨论】:
-
你运行的是什么版本的 Powershell?
-
@mjolinor Windows 8 自带的默认power shell。
-
@IbrahiemRafiq 在 Powershell 中运行
(get-host).version或get-host以查看版本号。 -
@mjolinor 版本 4.0
标签: powershell batch-file active-directory windows-server-2003 sid