Regkey カウントをテキスト ファイルに取得する PS スクリプトがあります。タスク スケジューラでこのスクリプトを使用しています。そのファイルの内容を取得して、タスクの実行後にイベント ビューアに記録できるかどうか教えてください。スクリプトは以下に記載されています-
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"
}
}