Export a hashtable-valued property to a CSV file

前端 未结 2 693
暖寄归人
暖寄归人 2021-01-15 08:35

I\'m running the Test-AdfsServerHealth (Ref.)

The problem is, one of the output values (value name Output) is an array that shows up as

2条回答
  •  天涯浪人
    2021-01-15 08:41

    This won't be significantly difficult, just going to be annoying to do. The reason you are getting "System.collections.hashtable" is because is unable to display everything in that property in a single format like that, there is way to much information. You will have to create another object and put whatever information you want in there.

    This prob won't work exactly like you want, but with some tweaking it should get you there.

    $ServerResult = Test-ADFSServerHealth
    $Object = New-PSObject -Property @{
        'Name' = $ServerResult.name
        'Result' = $ServerResult.Result
        'Detail' = $ServerResult.Detail
        'Output' = ($ServerResult.Output | out-string -stream)
        'ExceptionMessage' = $ServerResult.ExceptionMessage
    
        }
    

    If your interested, here are the resources I used to find this answer.
    Converting hashtable to array of strings
    https://devops-collective-inc.gitbooks.io/the-big-book-of-powershell-gotchas/content/manuscript/new-object_psobject_vs_pscustomobject.html

提交回复
热议问题