Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 为什么在尝试存档安全事件日志时会出现此错误? $EventLog=Get WmiObject Win32\u NTEventlogFile-Filter“LogFileName=‘Security’” $Date=获取日期-格式yyyyMMdd $Path=“C:\Users\aamous\Desktop\SecurityLogs” $EventLog.BackupEventlog($Path\$env:COMPUTERNAME`\u Security\$Date.evt) 清除事件日志-日志名安全性_Powershell_Wmi_Event Log_Get Wmiobject - Fatal编程技术网

Powershell 为什么在尝试存档安全事件日志时会出现此错误? $EventLog=Get WmiObject Win32\u NTEventlogFile-Filter“LogFileName=‘Security’” $Date=获取日期-格式yyyyMMdd $Path=“C:\Users\aamous\Desktop\SecurityLogs” $EventLog.BackupEventlog($Path\$env:COMPUTERNAME`\u Security\$Date.evt) 清除事件日志-日志名安全性

Powershell 为什么在尝试存档安全事件日志时会出现此错误? $EventLog=Get WmiObject Win32\u NTEventlogFile-Filter“LogFileName=‘Security’” $Date=获取日期-格式yyyyMMdd $Path=“C:\Users\aamous\Desktop\SecurityLogs” $EventLog.BackupEventlog($Path\$env:COMPUTERNAME`\u Security\$Date.evt) 清除事件日志-日志名安全性,powershell,wmi,event-log,get-wmiobject,Powershell,Wmi,Event Log,Get Wmiobject,我正在运行上面的脚本,但得到下面的错误 不能对空值表达式调用方法。 第6行字符:1 +$EventLog.BackupEventlog(“$Path\$env:COMPUTERNAME`Security$Date.evt…”。。。 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +CategoryInfo:InvalidOperation:(:)[],运行时异常 +FullyQualifiedErro

我正在运行上面的脚本,但得到下面的错误

不能对空值表达式调用方法。 第6行字符:1 +$EventLog.BackupEventlog(“$Path\$env:COMPUTERNAME`Security$Date.evt…”。。。 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +CategoryInfo:InvalidOperation:(:)[],运行时异常 +FullyQualifiedErrorId:InvokeMethodOnFull


$EventLog
是错误指示行中唯一可以是
$null
的内容。如果我尝试执行初始化
$EventLog
的命令,我发现它不会返回任何内容

PS>Get WmiObject Win32\u NTEventlogFile-Filter“LogFileName=‘Security’”
PS>
如果我从
获取WmiObject
命令中删除
-Filter
,以下是我作为标准用户在Windows 10系统上看到的日志

PS>获取WmiObject Win32\u NTEventlogFile
FileSize日志文件名Name NumberOfRecords
-------- -----------            ----                                                        ---------------
15798272应用程序C:\WINDOWS\System32\Winevt\Logs\Application.evtx 27698
69632硬件事件C:\WINDOWS\System32\Winevt\Logs\HardwareEvents.evtx 0
69632 Internet Explorer C:\WINDOWS\System32\Winevt\Logs\Internet Explorer.evtx 0
69632密钥管理服务C:\WINDOWS\System32\Winevt\Logs\Key Management Service.evtx 0
69632参数C:\WINDOWS\System32\Winevt\Logs\Parameters.evtx 0
69632状态C:\WINDOWS\System32\Winevt\Logs\State.evtx 0
14749696系统C:\WINDOWS\System32\Winevt\Logs\System.evtx 24168
15732736 Windows PowerShell C:\Windows\System32\Winevt\Logs\Windows PowerShell.evtx 10470
…作为一个高级用户

PS>获取WmiObject Win32\u NTEventlogFile
FileSize日志文件名Name NumberOfRecords
-------- -----------            ----                                                        ---------------
15798272应用程序C:\WINDOWS\System32\Winevt\Logs\Application.evtx 27698
69632硬件事件C:\WINDOWS\System32\Winevt\Logs\HardwareEvents.evtx 0
69632 Internet Explorer C:\WINDOWS\System32\Winevt\Logs\Internet Explorer.evtx 0
69632密钥管理服务C:\WINDOWS\System32\Winevt\Logs\Key Management Service.evtx 0
69632参数C:\WINDOWS\System32\Winevt\Logs\Parameters.evtx 0
20975616安全C:\WINDOWS\System32\Winevt\Logs\Security.evtx 29714
69632状态C:\WINDOWS\System32\Winevt\Logs\State.evtx 0
14749696系统C:\WINDOWS\System32\Winevt\Logs\System.evtx 24170
15732736 Windows PowerShell C:\Windows\System32\Winevt\Logs\Windows PowerShell.evtx 10477
请注意,
Security
日志仅在提升cmdlet运行时可用。因此,如果我以提升用户身份运行原始命令,则它可以访问
Security
日志

PS>Get WmiObject Win32\u NTEventlogFile-Filter“LogFileName=‘Security’”
FileSize日志文件名Name NumberOfRecords
-------- ----------- ----                                          ---------------
20975616安全C:\WINDOWS\System32\Winevt\Logs\Security.evtx 29723

Security
日志是为系统使用而设计的。但是,如果用户被授予了
seu Security\u NAME
权限(“管理审核和安全日志”用户权限),则可以读取和清除
Security
日志


$EventLog
是错误指示行中唯一可以是
$null
的内容。如果我尝试执行初始化
$EventLog
的命令,我发现它不会返回任何内容

PS>Get WmiObject Win32\u NTEventlogFile-Filter“LogFileName=‘Security’”
PS>
如果我从
获取WmiObject
命令中删除
-Filter
,以下是我作为标准用户在Windows 10系统上看到的日志

PS>获取WmiObject Win32\u NTEventlogFile
FileSize日志文件名Name NumberOfRecords
-------- -----------            ----                                                        ---------------
15798272应用程序C:\WINDOWS\System32\Winevt\Logs\Application.evtx 27698
69632硬件事件C:\WINDOWS\System32\Winevt\Logs\HardwareEvents.evtx 0
69632 Internet Explorer C:\WINDOWS\System32\Winevt\Logs\Internet Explorer.evtx 0
69632密钥管理服务C:\WINDOWS\System32\Winevt\Logs\Key Management Service.evtx 0
69632参数C:\WINDOWS\System32\Winevt\Logs\Parameters.evtx 0
69632状态C:\WINDOWS\System32\Winevt\Logs\State.evtx 0
14749696系统C:\WINDOWS\System32\Winevt\Logs\System.evtx 24168
15732736温多