Andrew Watt [MVP]
2007-01-15 14:26:09 UTC
Hi,
Have a look at the set-content and add-content cmdlets.
Andrew Watt MVP
On Mon, 15 Jan 2007 05:08:00 -0800, Kjetil Thorstensen
Have a look at the set-content and add-content cmdlets.
Andrew Watt MVP
On Mon, 15 Jan 2007 05:08:00 -0800, Kjetil Thorstensen
Hi.
I'm trying to write a script that parses logfiles, both IIS and other apps'
logs and extracts certain information from specific lines ... not all. The
extraction works fine using $var.substring and family, but I can't find out
how to write the info to a file.
I read the file into the variable (array) called $loglines and plan to
foreach ($i in $loglines) {
if ($loglines[$i].Contains("Process file") ) {
$Time=$loglines[$i].substring(0,14)
$Directory=$loglines[$i].substring( $loglines[$i].IndexOf("\"),
($loglines[$i].LastIndexOf("\")-$loglines[$i].IndexOf("\")))
$Filename=$loglines[14].substring($loglines[$i].LastIndexOf("\")+1,($loglines[$i].Length-$loglines[$i].LastIndexOf("\")-1))
# Here I need to get it to file, one line at a time
}
}
Ideas anyone?
Thanks in advance
/Kjetil
I'm trying to write a script that parses logfiles, both IIS and other apps'
logs and extracts certain information from specific lines ... not all. The
extraction works fine using $var.substring and family, but I can't find out
how to write the info to a file.
I read the file into the variable (array) called $loglines and plan to
foreach ($i in $loglines) {
if ($loglines[$i].Contains("Process file") ) {
$Time=$loglines[$i].substring(0,14)
$Directory=$loglines[$i].substring( $loglines[$i].IndexOf("\"),
($loglines[$i].LastIndexOf("\")-$loglines[$i].IndexOf("\")))
$Filename=$loglines[14].substring($loglines[$i].LastIndexOf("\")+1,($loglines[$i].Length-$loglines[$i].LastIndexOf("\")-1))
# Here I need to get it to file, one line at a time
}
}
Ideas anyone?
Thanks in advance
/Kjetil