从事件获取sid并将其转换回用户名

时间:2017-01-19 14:32:33

标签: event-log sid get-winevent

我尝试使用下面的命令从特定事件中获取用户sid,将其转换为用户名,然后输出其值。

$sid = Get-Winevent -FilterHashtable @{Logname='system';ID=1065} -MaxEvents 1 | Select User -ExpandProperty Userid
$objSID = New-Object System.Security.Principal.SecurityIdentifier ($sid)
$objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
$objUser.Value

我无法找到它无法正常工作的原因。它无法解码用户名。 $objUser应存储SID的用户名。我尝试将它用于域用户。 SID应该是有效的,因为我是从现有事件中获得的。

0 个答案:

没有答案
相关问题