2012-11-14 2 views
1

텍스트 파일에 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"} 
) 
} 

나는 아래에 언급 된 다음 코드를 시도하고 내가 이벤트 뷰어에 기록 아무것도 보이지 couldnt한다. 이걸 내게 좀 도와 줄 수 있니?

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" 
} 
} 

답변

0

왜 당신은 단순히 파일의 내용을 읽고 스크립트의 끝에서 특정 이벤트 로그에 기록 write-eventlog 같은 명령을 사용하지 마십시오? 어떤 문제가 발생합니까?

하나의 작업을 실행하는 데 대한 정보는 http://blogs.msdn.com/b/davethompson/archive/2011/10/25/running-a-scheduled-task-after-another.aspx에서 살펴보면 위의 파일을 읽고 이벤트 로그에 기록하는 두 번째 작업을 만들 수 있습니다.

이 질문에 대한 답변을 얻지 못하면 정확히 문제가 있습니까?

관련 문제