Populating datagridview from an object?

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
supportMIB
Posts: 55
Last visit: Tue Jun 22, 2021 9:24 am

Populating datagridview from an object?

Post by supportMIB »

I have some REST API code that pulls into powershell as an array of objects such as the output below:
  1. created_by         : @{id=27301; name=}
  2. site               :
  3. template           : @{id=1501; name=Modify Security Access}
  4. requester          : @{id=27301; name=}
  5. technician         :
  6. status             : @{id=1; color=#0066ff; name=Open}
  7. subject            : Please make the security changes listed for the employee noted.
  8. is_overdue         : False
  9. due_by_time        : @{display_value=Jun 22, 2021 09:36 AM; value=1624372607116}
  10. id                 : 6197
  11. time_elapsed       :
  12. short_description  : Description here
  13. priority           : @{id=2; color=#006600; name=Affects a user; no workaround is available.}
  14. group              : @{id=302; name=IT General}
  15. created_time       : @{display_value=Jun 21, 2021 02:36 PM; value=1624304207116}
  16. is_service_request : False
  17.  
  18. created_by         : @{id=27301; name=}
  19. site               :
  20. template           : @{id=4; name=Default Request}
  21. requester          : @{id=27301; name=}
  22. technician         :
  23. status             : @{id=1; color=#0066ff; name=Open}
  24. subject            : Telephone for the Computer Office
  25. is_overdue         : True
  26. due_by_time        : @{display_value=Jun 18, 2021 04:01 PM; value=1624050094004}
  27. id                 : 6185
  28. time_elapsed       :
  29. short_description  : Description here
  30. priority           : @{id=3; color=#ff6600; name=Affects some users; production is slowed. }
  31. group              : @{id=302; name=IT General}
  32. created_time       : @{display_value=Jun 18, 2021 02:01 PM; value=1624042894004}
  33. is_service_request : False
Is there a way to easily load each object as an item into a datagridview?

jvierra
Posts: 14867
Last visit: Fri Jul 23, 2021 7:52 pm
Answers: 12
Has voted: 3 times
Been upvoted: 10 times

Re: Populating datagridview from an object?

Post by jvierra »

That depends on what you want to load. The object is complex and hierarchical.

Locked