[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera!
Even when I use the less than and greater than signs is does not format the script correctly for me.
If Code Then
function ConvertIIS-LogFile { param( ) begin { } process { $file = [System.IO.File]::openText( $_.fullname ) while($line = $file.ReadLine()) { if(!$line.StartsWith('#') -and ($line.Length -gt 19)) { $UTCdatestring = $line.Substring(0, 19) $WorkDate = Get-Date($UTCdatestring) $LocalWorkDate = $WorkDate.tolocaltime() $FormatLocalWorkDate = $LocalWorkDate.ToString("yyyy-MM-dd HH:mm:ss") $StringLength = $line.length $RestOfString = $line.substring(19,$StringLength - 19) # $RestOfString | Out-Host $OutString = "$FormatLocalWorkDate"+"$RestOfString" Write-Output $OutString } ElseIF ($line.contains("Date:")) { $UTCdatestring = $line.Substring(7, 19) $WorkDate = Get-Date($UTCdatestring) $LocalWorkDate = $WorkDate.tolocaltime() $FormatLocalWorkDate = $LocalWorkDate.ToString("yyyy-MM-dd HH:mm:ss") $BeginString = $line.substring(0,6) $StringLength = $line.length $RestOfString = $line.substring(7+19,$StringLength - 19 -7) # $RestOfString | Out-Host $OutString = "$BeginString"+"$FormatLocalWorkDate"+"$RestOfString" Write-Output $OutString } Else { Write-Output $line } } } End {} } code>
Public Sub HelloWorld() Response.Write("Hello World") End Sub code>