【发布时间】:2023-04-07 03:09:02
【问题描述】:
在我的 csv 文件中,我有日期和时间列,但它是 UTC 时间,所以我只是想知道如何使用 PowerShell 将其转换为 EST 时间(12 小时或 24 小时格式)。我一直在谷歌上搜索如何做到这一点,但我还没有看到 Excel 列的任何解决方案。
function Convert-JSONColumn {
Write-Host "Start parsing Json Column"
$downloadFile = Import-Csv "C:\AuditLogSearch\Downloaded-Audit-Log-Records.csv"
$modifiedFile = "C:\AuditLogSearch\Modified-Audit-Log-Records.csv"
$downloadFile | ForEach-Object {
$jSON = $_.AuditData | ConvertFrom-Json
$epdata = ""
foreach ($ep in $jSON.extendedProperties) {
$epdata += $ep.Name + " : " + $ep.Value + "`n"
}
$paramdata = ""
foreach ($param in $jSON.Parameters) {
$paramdata += $param.Name + " : " + $param.Value + "`n"
}
New-Object PsObject -Property @{
RecordType = $_.RecordType
UserIds = $_.UserIds
Operations = $_.Operations
CreationTime = $jSON.CreationTime
Operation = $jSON.Operation
ObjectId = $jSON.ObjectId
}
} | Select-object -Property @(
@{Name = 'User'; Expression = 'UserId' }
@{Name = 'Date & Time'; Expression = 'CreationTime' }
@{Name = 'Type of Action'; Expression = 'Operation' }
@{Name = "Criteria"; Expression = "RecordType" }
@{Name = "Item Search"; Expression = "ObjectId" }
@{Name = "Result Status"; Expression = "ResultStatus" }
) | Export-Csv $modifiedFile -NoTypeInformation
这是 UTC 时间现在的样子。
2021-12-01T18:23:21
2021-12-01T18:23:21
2021-12-01T18:23:21
【问题讨论】:
-
为什么你认为 ISO 标准日期时间字符串是 utc?缺少时区段似乎表明......但它并不需要。 ///// PS - 请不要发布数据图像。我不需要输入就无法使用它......而且我不会做需要的工作,因为你是选择让它“需要”的人。
-
@Lee_Dailey 嗨.. 感谢您的反馈,我更新了我的帖子。谢谢
标签: powershell csv powershell-2.0