Public/update-allegisidnsourceschemaimportfromfile.ps1

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
    }
}