A piece of my work around PowerShell and IIS (or usefull things I've found on the web). Mostly some reminders for myself!

Someone asked me recently how to convert a field value in a CSV file before to process the file with Log Parser. The value in this example is in bytes and needs to be converted to terabytes. The column name that contains this value is ‘BytesColumn’.
Here we go:

 

$file=Import-Csv "C:\input.csv"
$file | ForEach-Object { $_.BytesColumn=[Math]::Round(($_.BytesColumn/1TB),4,[MidPointRounding]::AwayFromZero) }
$file | Export-Csv "C:\output.csv" -NoTypeInformation

Name*Email*WebsiteComment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top