Issue with Hash in chart creation

前端 未结 2 1719
情歌与酒
情歌与酒 2021-01-28 19:04

I am trying to create chart by Get-CorpChart-FullEdition script, which I found very good in chart creation.

On the website I found below instruction.

相关标签:
2条回答
  • 2021-01-28 19:17

    -data expects an array of objects, not a hashtable.

    0 讨论(0)
  • 2021-01-28 19:33

    If you wanted to use a hashtable I think you can if you call the .GetEnumarator() method

    which effectively sends each entry in the hash table across the pipeline as a separate object.

    . "D:\Auto\Get-Corpchart-LightEdition.ps1" -data $active_inactive.GetEnumerator() -obj_key "Name" -obj_value "Value" -filepath "c:\chart1.png" -type pie
    

    Looking at the code for the light edition of the script the parameter is expecting an [array] and not a hashtable.

    You would be better of creating your own custom objects from that hashtable's data depending on how complex your date would get.

    [pscustomobject]@{
        State="Active"
        Value=15
    },[pscustomobject]@{
        State="Inactive"
        Value=25
    }
    

    Tonnes of ways to do this more effectively so the above is just an example.

    0 讨论(0)
提交回复
热议问题