Skip to content

Instantly share code, notes, and snippets.

@daviesj
daviesj / Export-CsvWithMilliseconds.ps1
Last active September 30, 2024 20:49 — forked from sba923/Export-CsvWithMilliseconds.ps1
Improvement on Export-Csv that includes milliseconds in DateTime properties
#requires -version 7.3
# this is one of Stéphane BARIZIEN's public domain scripts
# the most recent version can be found at:
# https://gist.github.com/sba923/bc52cf74197ab3cddce825e8b502e28b#file-export-csvwithmilliseconds-ps1
<#
.SYNOPSIS
Proxy for Export-Csv that adds milliseconds to DateTime properties
@daviesj
daviesj / Convert-DateTimePropertiesToStringWithMilliseconds.ps1
Created September 30, 2024 19:57 — forked from sba923/Convert-DateTimePropertiesToStringWithMilliseconds.ps1
Convert all DateTime properties of objects on the pipeline to strings including milliseconds, to work around Export-CSV's limitation
# this is one of Stéphane BARIZIEN's public domain scripts
# the most recent version can be found at:
# https://gist.github.com/sba923/ddc6e300e2bbe3f01d1ee20276d0cfe4#file-convert-datetimepropertiestostringwithmilliseconds-ps1
#requires -Version 7.3
# this rewrites the objects on the pipeline so that DateTime members are replaced with a string representation including milliseconds
# to work around the fact Export-CSV doesn't include milliseconds (see https://github.com/PowerShell/PowerShell/issues/19536)
# compute millisecond-aware version of the current datetime format