我有 PS 脚本来获取 Regkey 计数到文本文件。我在任务计划程序中使用此脚本&您能否告诉我我们是否可以获取该文件的内容并在任务运行后将其记录到事件查看器中?脚本在下面提到 -
if (!([diagnostics.process]::GetCurrentProcess().Path -match '\\syswow64\\'))
{
$uninstallPath = "\Software\Microsoft\Windows\CurrentVersion\Uninstall\"
$uninstallWow6432Path = "\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
@(
if (Test-Path "HKLM:$uninstallWow6432Path" ) {Get-ChildItem "HKLM:$uninstallWow6432Path"-Recurse | Measure-Object | Out-File "C:\PS Output\Total6432.txt"}
if (Test-Path "HKLM:$uninstallpath" ) {Get-ChildItem "HKLM:$UninstallPath" -Recurse | Measure-Object | Out-File "C:\PS Output\Total32.txt"}
)
}
我尝试了下面提到的以下代码,但在事件查看器中看不到任何内容。你能给我一些指导吗?
if (!([diagnostics.process]::GetCurrentProcess().Path -match '\\syswow64\\'))
{
$uninstallPath = "\Software\Microsoft\Windows\CurrentVersion\Uninstall\"
$uninstallWow6432Path = "\Software\Wow6432Node\Microsoft\Windows\CurrentVersion \Uninstall\"
@(
if (Test-Path "HKLM:$uninstallWow6432Path" ) {Get-ChildItem "HKLM:$uninstallWow6432Path"-Recurse | Measure-Object | Out-File "C:\PS Output\Total6432.txt"}
if (Test-Path "HKLM:$uninstallpath" ) {Get-ChildItem "HKLM:$UninstallPath" -Recurse | Measure-Object | Out-File "C:\PS Output\Total32.txt"}
)
$Content = Get-content -Path 'C:\PS Output\Total6432.txt'
$Content1 = Get-Content -Path 'C:\PS Output\Total32.txt'
{
Write-EventLog -LogName Application -Source $Content AND $Content1 -EventId 3001 -EntryType Information "Count is Registered"
}
}