Advertisement
Guest User

Untitled

a guest
Jul 31st, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. $guests = Import-Csv -Path C:Usersshant_000DesktopUploadGuest_test.csv
  2. $output = gc '.Sample Json.json' | ConvertFrom-Json
  3. $array = New-Object System.Collections.ArrayList;
  4.  
  5. foreach ($g in $guests) {
  6. $array.Add($output);
  7. $a = $array[$array.Count-1];
  8.  
  9. $a.Username = $g.'EmailAddress';
  10. $a.DisplayName = $g.'FirstName' + ' ' + $g.'LastName';
  11. $a.Password = $g.'LastName' + '123';
  12. $a.Email = $g.'EmailAddress';
  13.  
  14. foreach ($i in $a.ProfileProperties.Count) {
  15. $j = $i - 1;
  16.  
  17. $prop = $a.ProfileProperties[$j];
  18.  
  19. if ($prop.PropertyName -eq "FirstName") {
  20. $prop.PropertyValue = $g.'FirstName';
  21. } elseif ($prop.PropertyName -eq "LastName") {
  22. $prop.PropertyValue = $g.'LastName';
  23. }
  24.  
  25. $a.ProfileProperties[$j] = $prop;
  26. }
  27.  
  28. $array[$array.Count-1] = $a;
  29. }
  30.  
  31. $array;
  32.  
  33. $jsontext = gc '.Sample Json.json'
  34. ..........
  35. foreach ($g in $guests) {
  36. $a = $jsontext | ConvertFrom-Json
  37.  
  38. # process $a
  39. # ............
  40.  
  41. $array.Add($a) >$null
  42. }
  43.  
  44. foreach ($g in $guests) {
  45. $a = $output.PSObject.Copy()
  46. # ............
  47.  
  48. $a.ProfileProperties = $a.ProfileProperties.PSObject.Copy()
  49. # ............
  50. foreach ($i in $a.ProfileProperties.Count) {
  51. # ............
  52. $prop = $a.ProfileProperties[$j].PSObject.Copy();
  53. # ............
  54. }
  55.  
  56. $array.Add($a) >$null
  57. }
  58.  
  59. bar
  60.  
  61. $o1
  62.  
  63. $json = Get-Content '.Sample Json.json' -Raw
  64. $array = foreach ($g in $guests) {
  65. $a = $json | ConvertFrom-Json # create new object
  66.  
  67. $a.Username = $g.'EmailAddress'
  68. ...
  69.  
  70. $a # echo object, so it can be collected in $array
  71. }
  72.  
  73. $json = Get-Content '.Sample Json.json' -Raw
  74. $array = foreach ($g in $guests) {
  75. $a = $json | ConvertFrom-Json # create new object
  76.  
  77. $a.Username = $g.'EmailAddress'
  78. ...
  79.  
  80. $a # echo object, so it can be collected in $array
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement