Freigeben über


Ever try to Export-CSV but information is missing in the CSV replaced SysInfo

This came from doing this command but one of the fields was not exporting…

 

[PS] C:\scripts>Get-MailboxDatabaseCopyStatus e2k10DB01 | Select
@{ n = "OutstandingDumpsterRequests"; e={$_.OutstandingDumpsterRequests}}
 |export-csv test.txt

 

Use this for any Fail Exports to CSV or similar to this....
"Microsoft.Exchange.Management.SystemConfigurationTasks.DumpsterRequestEntry[]"

 

You need to 1) use a Select Statement and 2) modify the Values not exporting.

Example.

 

Get-MailboxDatabaseCopyStatus e2k10DB01 | FL "OutstandingDumpsterRequests"
| Export-CSV C:\Test.txt

 

This will be my only entry:

"Microsoft.Exchange.Management.SystemConfigurationTasks.DumpsterRequestEntry[]"

Note: I remove the Export-CSV and this shows the correct {} Value on the Screen.

 

So Next just to show this one Value.

 

Get-MailboxDatabaseCopyStatus e2k10DB01 | Select @{ n = "OutstandingDumpsterRequests"
;e={$_.OutstandingDumpsterRequests}}
|Export-CSV C:\test.txt

 

My Entry will match the Output on the Screen

{}

 

So why does this work?

To specify a calculated property we need to create a hash table; that’s
what the @{} syntax does for us. Inside the curly braces we specify the two elements of our hash
table: the property Name (in this case, OutStandingDumpsterRequest) and the property Expression
(that is, the script block we’re going to use to calculate the property value). The Name property is
easy enough to specify; we simply assign a string value to the Name, like so


n = "OutstandingDumpsterRequests"

 

And, believe it or not, the Expression property (which is separated from the name by a semicolon)
isn’t much harder to configure; the only difference is that Expression gets assigned a script block
rather than a string value:


e={$_.OutstandingDumpsterRequests}

   

Thus this outputs the Data into the CSV


@{ n = "OutstandingDumpsterRequests";e={$_.OutstandingDumpsterRequests}}

   

Does NOT export the data for Outstanding DumsterRequest….

 

[PS] C:\scripts>Get-MailboxDatabaseCopyStatus e2k10DB01 | Select "Identity","Name","DatabaseName","Status","MailboxServer","ActiveDatabaseCopy",
"ActivationSuspended","ActionInitiator","ErrorMessage","ErrorEventId","ExtendedErrorInfo",
"SuspendComment","SinglePageRestore","ContentIndexState","ContentIndexErrorMessage",
"CopyQueueLength","ReplayQueueLength","LatestAvailableLogTime",
"LastCopyNotificationedLogTime","LastCopiedLogTime","LastInspectedLogTime",
"LastReplayedLogTime","LastLogGenerated","LastLogCopyNotified","LastLogCopied",
"LastLogInspected","LastLogReplayed","LogsReplayedSinceInstanceStart",
"LogsCopiedSinceInstanceStart","LatestFullBackupTime","LatestIncrementalBackupTime",
"LatestDifferentialBackupTime","LatestCopyBackupTime","SnapshotBackup",
"SnapshotLatestFullBackup","SnapshotLatestIncrementalBackup","SnapshotLatestDifferentialBackup",
"SnapshotLatestCopyBackup","LogReplayQueueIncreasing","LogCopyQueueIncreasing",
"OutstandingDumpsterRequests","OutgoingConnections","IncomingLogCopyingNetwork",
"SeedingNetwork","ActiveCopy"| Export-CSV test.txt

 

But this DOES

 

[PS] C:\scripts>Get-MailboxDatabaseCopyStatus e2k10DB01 | Select "Identity","Name","DatabaseName","Status","MailboxServer","ActiveDatabaseCopy",
"ActivationSuspended","ActionInitiator","ErrorMessage","ErrorEventId","ExtendedErrorInfo",
"SuspendComment","SinglePageRestore","ContentIndexState","ContentIndexErrorMessage",
"CopyQueueLength","ReplayQueueLength","LatestAvailableLogTime",
"LastCopyNotificationedLogTime","LastCopiedLogTime","LastInspectedLogTime",
"LastReplayedLogTime","LastLogGenerated","LastLogCopyNotified","LastLogCopied",
"LastLogInspected","LastLogReplayed","LogsReplayedSinceInstanceStart",
"LogsCopiedSinceInstanceStart","LatestFullBackupTime","LatestIncrementalBackupTime",
"LatestDifferentialBackupTime","LatestCopyBackupTime","SnapshotBackup",
"SnapshotLatestFullBackup","SnapshotLatestIncrementalBackup","SnapshotLatestDifferentialBackup",
"SnapshotLatestCopyBackup","LogReplayQueueIncreasing","LogCopyQueueIncreasing",
@{ n = "OutstandingDumpsterRequests";e=$_.OutstandingDumpterRequests}},
"OutgoingConnections","IncomingLogCopyingNetwork","SeedingNetwork","ActiveCopy"
| Export-CSV test.txt

  

 

Note: You may have to do this to several properties but it should work!