A quick way to generate a log file that can be used to feed write-eventlog
=========================================
$ErrorActionPreference="SilentlyContinue"
Stop-Transcript | out-null
$ErrorActionPreference = "Continue"
$Archivolog = "C:\temp\output-$(get-date -f yyyy-MM-dd_hh-mm-ss).txt"
$Archivolog2 = "C:\temp\compress-$(get-date -f yyyy-MM-dd_hh-mm-ss).txt"
Start-Transcript -path $Archivolog -append
Write-Host Step 1 Start at $(get-date)
gci -r C:\temp | where {$_.attributes -notmatch "compressed"} | foreach {compact /C $_.fullname } | out-file $Archivolog2 -Append
gc $Archivolog2
Write-Host Step 1 Finished at $(get-date)
Stop-Transcript
$text = [IO.File]::ReadAllText($Archivolog)
New-EventLog –LogName Application –Source "Nakama test"
Write-EventLog –LogName Application –Source "Nakama test" –EntryType Information –EventID 9213 –Message $text
=========================================
Wednesday, July 26, 2017
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment