问题-仅从安全事件日志获取部分数据。
我正在使用Powershell从2019年域控制器中提取安全事件。代码在服务器上运行良好,我可以看到所有数据(只要Powershell运行提升)。远程用户已添加到AD "Builtin“文件夹安全组”事件日志读取器“中。远程获取事件的部分数据。例如,事件->属性->事件的SyncRoot部分远程为空。加误差
Method invocation failed because [Deserialized.System.Diagnostics.Eventing.Reader.EventLogRecord] does not contain a method named 'ToXml'.
那么,如何使特定的远程用户获得完全访问呢?
下面代码,谢谢
# On local server use the -Computername and -Credential are not used
$events = Invoke-Command -ComputerName $dc -Credential $cred -scriptblock {Get-WinEvent -LogName Security -FilterXPath "*[System[EventID=4624] and EventData[Data[@Name='TargetUserName']=`'$using:account`']]"}
foreach ($event in $events)
{
# Convert the event to XML
$eventXML = [xml]$event.ToXml() # error when used remotely发布于 2021-07-23 03:55:27
您所拥有的错误与权限无关,而是与Invoke-Command 反序列化有关。
但是,反序列化对象不是活动对象。它是序列化对象时对象的快照,它包含属性,但不包含任何方法。
避免这种情况的一种方法是将日志转换为远程主机中的XML:
$events = Invoke-Command -ComputerName $dc -Credential $cred -ScriptBlock {
$logs = Get-WinEvent -LogName Security -FilterXPath "*[System[EventID=4624] and EventData[Data[@Name='TargetUserName']=`'$using:account`']]"
$logs.ForEach({$_.ToXml()})
}
foreach($event in $events)
{
[xml]$event
}乔布斯身上也发生了类似的事情:
$log = Get-WinEvent -LogName Application -MaxEvents 1
$log.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False EventLogRecord System.Diagnostics.Eventing.Reader.EventRecord$log = Start-Job {Get-WinEvent -LogName Application -MaxEvents 1} |
Receive-Job -Wait -AutoRemoveJob
$log.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True PSObject System.Object
$log.ToXml()
Method invocation failed because [Deserialized.System.Diagnostics.Eventing.Reader.EventLogRecord] does not contain a method named 'ToXml'.
...
...https://stackoverflow.com/questions/68493487
复制相似问题