Public/update-allegisidnsourceschemaimportfromfile.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
function update-allegisidnsourceschemaimportfromfile ([string]$orgname,[string]$accessToken,[string]$fileinput,[string[]]$source,[string]$log) { <# .SYNOPSIS Updates Updates the Schema for an IDN Source .PARAMETER Orgname Organization Name (allegis) .PARAMETER AccessToken Access Token for the environment .PARAMETER fileinput This is a CSV of the attributes to compare .PARAMETER Source IDN Source IDs ie ('94652','26468') .PARAMETER Log this is for transcript end the file in .log .INPUTS $file inputs must have IDN = T/F; type = type of value (string,INT,LONG); ldapdisplayname = name of the attribute to compare/update; multi = True/False If the value is multivalue or not. .OUTPUTS It can output a log file if you fill in $log var. Set-Item #> if ($log -ne $null) { Start-Transcript -Path $log } $import = Import-Csv $fileinput | Where-Object {$_.idn -eq $true} foreach ($sourceid in $source) { $sourceImport = $null $compare = $null #pull Source Records $sourceImport = (get-AllegisIDNsourceSchemaImport -accessToken $accesstoken -orgName $orgname -sourceid $sourceid).attributes | select name,type,multi,description #compare file and Schema $compare = Compare-Object -ReferenceObject $import.ldapdisplayname -DifferenceObject $sourceImport.name -IncludeEqual $counter1 = 0 Write-Progress -id 1 -Activity "group" -CurrentOperation $sourceid -PercentComplete (($counter1/$source.count)*100) $counter1++ $counter = 0 foreach ($object in $compare | ? {$_.sideindicator -eq "<="}) { Write-Progress -ParentId 1 -Id 2 -Activity "user" -CurrentOperation $object -PercentComplete (($counter/$compare.count)*100) $counter++ $fileimport = $import | where-object {$_.ldapdisplayname -eq $object.inputobject} $description = $fileimport.ldapdisplayname $name = $fileimport.ldapdisplayname $type = $fileimport.type $multi = $fileimport.multi try { new-AllegisIDNsourceSchemaImportAttribute -accessToken $accessToken -description $description -name $name -orgName $orgname -sourceid $sourceid -type $type -multi $multi Write-Host "Attribute was updated: Source = $sourceid Attribute: $name" } catch { Write-Host "$name Attribute failed to update in IdentityNow $sourceid" } } } if ($log -ne $null) { Stop-Transcript } } |