Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $guests = Import-Csv -Path C:Usersshant_000DesktopUploadGuest_test.csv
- $output = gc '.Sample Json.json' | ConvertFrom-Json
- $array = New-Object System.Collections.ArrayList;
- foreach ($g in $guests) {
- $array.Add($output);
- $a = $array[$array.Count-1];
- $a.Username = $g.'EmailAddress';
- $a.DisplayName = $g.'FirstName' + ' ' + $g.'LastName';
- $a.Password = $g.'LastName' + '123';
- $a.Email = $g.'EmailAddress';
- foreach ($i in $a.ProfileProperties.Count) {
- $j = $i - 1;
- $prop = $a.ProfileProperties[$j];
- if ($prop.PropertyName -eq "FirstName") {
- $prop.PropertyValue = $g.'FirstName';
- } elseif ($prop.PropertyName -eq "LastName") {
- $prop.PropertyValue = $g.'LastName';
- }
- $a.ProfileProperties[$j] = $prop;
- }
- $array[$array.Count-1] = $a;
- }
- $array;
- $jsontext = gc '.Sample Json.json'
- ..........
- foreach ($g in $guests) {
- $a = $jsontext | ConvertFrom-Json
- # process $a
- # ............
- $array.Add($a) >$null
- }
- foreach ($g in $guests) {
- $a = $output.PSObject.Copy()
- # ............
- $a.ProfileProperties = $a.ProfileProperties.PSObject.Copy()
- # ............
- foreach ($i in $a.ProfileProperties.Count) {
- # ............
- $prop = $a.ProfileProperties[$j].PSObject.Copy();
- # ............
- }
- $array.Add($a) >$null
- }
- bar
- $o1
- $json = Get-Content '.Sample Json.json' -Raw
- $array = foreach ($g in $guests) {
- $a = $json | ConvertFrom-Json # create new object
- $a.Username = $g.'EmailAddress'
- ...
- $a # echo object, so it can be collected in $array
- }
- $json = Get-Content '.Sample Json.json' -Raw
- $array = foreach ($g in $guests) {
- $a = $json | ConvertFrom-Json # create new object
- $a.Username = $g.'EmailAddress'
- ...
- $a # echo object, so it can be collected in $array
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement