Guest User

Untitled

a guest
Jan 16th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. $a = Import-Csv .table1.txt
  2. $a | FT -AutoSize
  3. $Duration = Measure-Command {
  4. $b = @()
  5. foreach ($Property in $a.Property | Select -Unique) {
  6. $Props = [ordered]@{ Property = $Property }
  7. foreach ($Server in $a.Server | Select -Unique){
  8. $Value = ($a.where({ $_.Server -eq $Server -and
  9. $_.Property -eq $Property })).Value
  10. $Props += @{ $Server = $Value }
  11. }
  12. $b += New-Object -TypeName PSObject -Property $Props
  13. }
  14. }
  15.  
  16. Write-Host "Finished transposing " -ForegroundColor Green -NoNewline
  17. Write-Host "$(($a | Get-Member -MemberType Properties).count)/$($a.Count)" -ForegroundColor Yellow -NoNewline
  18. Write-Host " columns/rows into " -ForegroundColor Green -NoNewline
  19. Write-Host "$(($b | Get-Member -MemberType Properties).count)/$($b.Count)" -ForegroundColor Yellow -NoNewline
  20. Write-Host " columns/rows in " -ForegroundColor Green -NoNewline
  21. Write-Host $Duration.Milliseconds -ForegroundColor Yellow -NoNewline
  22. Write-Host " Milliseconds" -ForegroundColor Green
  23.  
  24. $b | FT -AutoSize
  25. $b | Out-GridView
  26. $b | Export-Csv .table2.txt -NoTypeInformation
  27.  
  28. $a = Import-Csv .table1.txt
  29. $a | FT -AutoSize
  30. $Duration = Measure-Command {
  31. $b = @()
  32. foreach ($Property in $a.Property | Select -Unique) {
  33. $Props = [ordered]@{ Property = $Property }
  34. foreach ($Server in $a.Server | Select -Unique){
  35. $Value = ($a.where({ $_.Server -eq $Server -and
  36. $_.Property -eq $Property })).Value
  37. $Props += @{ $Server = $Value }
  38. }
  39. $b += New-Object -TypeName PSObject -Property $Props
  40. }
  41. }
  42.  
  43. Write-Host "Finished transposing " -ForegroundColor Green -NoNewline
  44. Write-Host "$(($a | Get-Member -MemberType Properties).count)/$($a.Count)" -ForegroundColor Yellow -NoNewline
  45. Write-Host " columns/rows into " -ForegroundColor Green -NoNewline
  46. Write-Host "$(($b | Get-Member -MemberType Properties).count)/$($b.Count)" -ForegroundColor Yellow -NoNewline
  47. Write-Host " columns/rows in " -ForegroundColor Green -NoNewline
  48. Write-Host $Duration.Milliseconds -ForegroundColor Yellow -NoNewline
  49. Write-Host " Milliseconds" -ForegroundColor Green
  50.  
  51. $b | FT -AutoSize
  52. $b | Out-GridView
  53. $b | Export-Csv .table2.txt -NoTypeInformation
  54.  
  55. $a = Import-Csv .table1.txt
  56. $a | FT -AutoSize
  57. $Duration = Measure-Command {
  58. $b = @()
  59. foreach ($Property in $a.Property | Select -Unique) {
  60. $Props = [ordered]@{ Property = $Property }
  61. foreach ($Server in $a.Server | Select -Unique){
  62. $Value = ($a.where({ $_.Server -eq $Server -and
  63. $_.Property -eq $Property })).Value
  64. $Props += @{ $Server = $Value }
  65. }
  66. $b += New-Object -TypeName PSObject -Property $Props
  67. }
  68. }
  69.  
  70. Write-Host "Finished transposing " -ForegroundColor Green -NoNewline
  71. Write-Host "$(($a | Get-Member -MemberType Properties).count)/$($a.Count)" -ForegroundColor Yellow -NoNewline
  72. Write-Host " columns/rows into " -ForegroundColor Green -NoNewline
  73. Write-Host "$(($b | Get-Member -MemberType Properties).count)/$($b.Count)" -ForegroundColor Yellow -NoNewline
  74. Write-Host " columns/rows in " -ForegroundColor Green -NoNewline
  75. Write-Host $Duration.Milliseconds -ForegroundColor Yellow -NoNewline
  76. Write-Host " Milliseconds" -ForegroundColor Green
  77.  
  78. $b | FT -AutoSize
  79. $b | Out-GridView
  80. $b | Export-Csv .table2.txt -NoTypeInformation
Add Comment
Please, Sign In to add comment