Using get-winevent in powershell with XML filter, you can grab the 2889 events from the directory services log. These contain the username, and source IP. With some custom defined attributes within select-object along with an array, you can filter this down to unique connections.
$query = @"
<QueryList>
<Query Id="0" Path="Directory Service">
<Select Path="Directory Service">*[System[(EventID=2889)]]</Select>
</Query>
</QueryList>
"@
$somelistofdomaincontrollers | %{
$serv = $_
$hashes = @();
get-winevent -filterxml $query | select @{n="dc";e={$_.machinename}},
@{n="source";e={($_.properties.value[0].split(":"))[0]}},
@{n="user";e={$_.properties.value[1]}},
@{n='connhash';e={$str = ($_.machinename +
$_.properties.value[0].split(":"))[0] +
$_.properties.value[1]; $str.gethashcode()}} | %{
if ($hashes.contains($_.connhash)) {} else {$hashes += $_.connhash; $_|
select dc,source,user}
}
No comments:
Post a Comment