# make sure the property gets piped to Out-String to turn its # content into readable text that can be displayed in the report $replacementStrings = @{ Name = 'ReplacementStrings' Expression = { ($_.ReplacementStrings | Out-String).Trim() } }
Get-EventLog-LogName System -EntryType Error -After$startDate | # select the properties to be included in your report Select-Object-Property EventId, Message, Source, InstanceId, TimeGenerated, $ReplacementStrings, UserName | ConvertTo-Html | Set-Content-Path$Path
# make sure the property gets piped to Out-String to turn its # content into readable text that can be displayed in the report $replacementStrings = @{ Name = 'ReplacementStrings' Expression = { $_.ReplacementStrings -join',' } }
Get-EventLog-LogName System -EntryType Error -After$startDate | # select the properties to be included in your report Select-Object-Property EventId, Message, Source, InstanceId, TimeGenerated, $ReplacementStrings, UserName | ConvertTo-Html | Set-Content-Path$Path
Get-EventLog-LogName System -EntryType Error -After$startDate | # select the properties to be included in your report Select-Object-Property EventId, Message, Source, InstanceId, TimeGenerated, ReplacementStrings, UserName | ConvertTo-Html | Set-Content-Path$Path
Title Operation Date ------------------ Definitionsupdate für Windows Defender – KB2267602 (Definition 1.249.348.0) Installation 28.07.20... Definitionsupdate für Windows Defender – KB2267602 (Definition 1.249.281.0) Installation 27.07.20... Definitionsupdate für Windows Defender – KB2267602 (Definition 1.249.237.0) Installation 26.07.20... Definitionsupdate für Windows Defender – KB2267602 (Definition 1.249.191.0) Installation 25.07.20... Definitionsupdate für Windows Defender – KB2267602 (Definition 1.249.139.0) Installation 24.07.20... Definitionsupdate für Windows Defender – KB2267602 (Definition 1.249.95.0) Installation 22.07.20... Definitionsupdate für Windows Defender – KB2267602 (Definition 1.249.93.0) Installation 22.07.20... Definitionsupdate für Windows Defender – KB2267602 (Definition 1.249.28.0) Installation 21.07.20... Definitionsupdate für Windows Defender – KB2267602 (Definition 1.249.13.0) Installation 20.07.20... Definitionsupdate für Windows Defender – KB2267602 (Definition 1.247.1068.0) Installation 19.07.20... Definitionsupdate für Windows Defender – KB2267602 (Definition 1.247.1010.0) Installation 18.07.20... Definitionsupdate für Windows Defender – KB2267602 (Definition 1.247.969.0) Installation 17.07.20... Definitionsupdate für Windows Defender – KB2267602 (Definition 1.247.966.0) Installation 17.07.20...
$ExecutionContext.SessionState.InvokeCommand.PreCommandLookupAction = { # is called whenever a command is ready to execute param($command, $eventArgs)
# check commands that start with "*" and were not # executed internally by PowerShell if ($command.StartsWith('*') -and$eventArgs.CommandOrigin -eq'Runspace') { # save command output here $debugPath = "$env:temp\debugOutput.txt" # clear text file if it exists $exists = Test-Path$debugPath if ($exists) { Remove-Item-Path$debugPath } # remove leading "*" from a command name $command = $command.Substring(1) # tell PowerShell what to do instead of # running the original command $eventArgs.CommandScriptBlock = { # run the original command without "*", and # submit original arguments if there have been any $( if ($args.Count -eq0) { & $command } else { & $command$args } ) | # log output to file Tee-Object-FilePath$debugPath | # open the file once all output has been processed ForEach-Object-Process { $_ } -End { if (Test-Path$debugPath) { notepad $debugPath } } }.GetNewClosure() } }