$Type = "Error" $LogFile = "c:\LogFile.txt" $NewestLogID = 500 Out-File $LogFile Out-File $LogFile -append -inputobject " >>@---------------------------@< <" Out-File $LogFile -append -inputobject " >>@--- System EventLog ---@< <" Out-File $LogFile -append -inputobject " >>@---------------------------@< <" $Log = "System" Get-EventLog -computername MyComputer -logname $Log -newest $NewestLogID | ForEach-Object { If ($_.EntryType -eq $Type) { Out-File $LogFile -append -inputobject $_.timewritten Out-File $LogFile -append -inputobject $_.Source Out-File $LogFile -append -inputobject $_.Message } } Out-File $LogFile -append -inputobject " " Out-File $LogFile -append -inputobject " >>@--------------------------------@< <" Out-File $LogFile -append -inputobject " >>@--- Application EventLog ---@< <" Out-File $LogFile -append -inputobject " >>@--------------------------------@< <" $Log = "Application" Get-EventLog -computername MyComputer -logname $Log -newest $NewestLogID | ForEach-Object { If ($_.EntryType -eq $Type) { Out-File $LogFile -append -inputobject $_.timewritten Out-File $LogFile -append -inputobject $_.Source Out-File $LogFile -append -inputobject $_.Message } }