Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. $columns = ($datatable | Get-Member -MemberType Property).Name
  2. foreach($column in $Columns) {
  3. $max = 0
  4. foreach ($a in $datatable){
  5. if($max -lt $a.$column.length){
  6. $max = $a.$column.length
  7. }
  8. }
  9. $output = New-Object psobject
  10. $output | Add-Member NoteProperty Column ($column)
  11. $output | Add-Member NoteProperty Max ($max)
  12.  
  13. Write-Output $output
  14. }
  15.  
  16. Column Max
  17. A 3
  18. A 4
  19. A 5
  20. B 10
  21. C 19
  22. C 29
  23. D 9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement