Couple things with this, first I'm wanting to convert the output from LastTransferEndTimestamp to a human readable date. I've read a few articles that demonstrate how to convert the output using get-date and I've had good success but I'm struggling to get the syntax correct to make the conversion on single line nested in foreach loop.
No struggles here
PS C:\> $date = (Get-Date '1970-01-01').AddSeconds(1471979101)
PS C:\> $date.GetDateTimeFormats('s')
2016-08-23T19:05:01
My questions, how can I achieve the desired result with the code below? I like the flexibility of using the code below but, am I over complicating it?
I struggle here.
$mirrors = @()
foreach ($controller in @($controllers)) {
Connect-NcController $controller
# Collect desired volumes from controllers and store in variable
$mirrors += Get-NcSnapmirror -Controller $_ | Where-Object {$_.DestinationVolume -match 'Prod_SQL'}
} #foreach
$reportData = foreach ($mirror in $mirrors) {
# Create object with values
[PSCustomObject][ordered]@{
'Destination_SVM' = $mirror.DestinationVserver
'Destination_Vol' = $mirror.DestinationVolume
'Status' = $mirror.status
'LagTime' = $mirror.LagTime
'LastTransDuration' = $mirror.LastTransferDuration
'LastTransSize_GB' = $mirror.LastTransferSize / 1tb | % {$_.ToString("#.##")}
'LastTransError' =$mirror.LastTransferError
'LastTransEnd' =$mirror.LastTransferEndTimestamp
'TranferRateMax' =$mirror.CurrentMaxTransferRate
'ExportSnapshot' =$mirror.ExportedSnapshot
'SnapshotTimestamp' =$mirror.CurrentMaxTransferRateExportedSnapshotTimestamp
'Break/fail' = $mirror.BreakFailedCount
'CatalogStatus' = $mirror.CatalogStatus;
}
}
Thanks in advance