Q:

powershell append date time to beginning of file

I'm working to get a powershell command that will dump the value into output.xml.  First a value is requested from the user, then the application log is parsed for that value and the results are returned to output.xml.  I would like to also tag the beginning with the date time stamp, but haven't been able to figure it out.  This is what I have come up with to accomplish the parsing, and I have attempted to use a few other methods:
read-host (Get-Date).tostring("dd-MM-yyyy-hh-mm-ss")

I guess I don't understand exactly where to put this part of the code to make it work.  My whole script looks like this. 
$value = read-host "Enter your search value"
Get-WinEvent -Logname application -EA silentlycontinue | ?{ $_.LevelDisplayName -eq "Error" -or $_.LevelDisplayName -eq "Warning"} | Out-File '$output.xml' -Append 

A:

Use Out-File to write the first line(s) of the file as well:
$value = Read-Host "Enter your search value"
"# $(Get-Date -Format 'dd-MM-yyyy-hh-mm-ss')" |Out-File output.log
"# User $($env:USERNAME) supplied the following search term '$value'" |Out-File output.log -Append
Get-WinEvent -Logname application -EA silentlycontinue | ?{ $_.LevelDisplayName -eq "Error" -or $_.LevelDisplayName -eq "Warning"} | Out-File output.log -Append

