Public/new-AllegisIDNIdentityProfileAttributeTransform.ps1
function new-AllegisIDNIdentityProfileAttributeTransform { param( [cmdletbinding( DefaultParameterSetName='AccountAttribute' )] [string]$orgname, [Parameter(Position = 0,Mandatory=$true)]$identityAttributeName, [Parameter(ParameterSetName='AccountAttribute',Mandatory=$true)]$sourcename, [Parameter(ParameterSetName='AccountAttribute',Mandatory=$true)]$sourceattribute, [string]$accesstoken, [string]$rule, [string]$transform, [switch]$PurgeAndRefreshReferenceInfo ) if ($PurgeAndRefreshReferenceInfo -eq $true -or $Global:idn_rule -eq $null -or $Global:idn_transformnames -eq $null -or $Global:idn_sourcesWithImportSchema -eq $null -or $Global:idn_orgname -ne $orgname) {#populate data Set-Variable -Scope 'Global' -Name 'idn_orgname' -Value $orgname Set-Variable -Scope 'Global' -Name 'idn_rule' -Value (get-AllegisIDNrule -orgName $sourceOrg -accessToken $accesstoken) Set-Variable -Scope 'Global' -Name 'idn_transformnames' -Value ((get-AllegisIDNtransform -orgName $sourceOrg -accessToken $accesstoken).items.id) Set-Variable -Scope 'Global' -Name 'idn_sourcesWithImportSchema' -Value (get-AllegisIDNsource -orgName $sourceOrg -accessToken $accesstoken -importschema) } $rules=$Global:idn_rule $transformnames=$Global:idn_transformnames $sourcesWithImportSchema=$Global:idn_sourcesWithImportSchema $validrules=$rules.items.where{$_.type -eq 'IdentityAttribute'}.name $source=$sourcesWithImportSchema.where{$_.name -eq $sourcename}[0] if ($source.importschema.attributes.where{$_.name -eq $sourceattribute} -eq $null){write-warning -Message "unable to find $sourcename : $sourceattribute in `sourcesWithImportSchema";return} if (($transform.length -gt 0 -and $transform -notin $transformnames)){write-warning -Message "provided transform name did not appear to be valid $transform";return} $accountattribute=[pscustomobject]@{ applicationId=$source.externalid applicationName="$($source.name) [source-$($source.id)]" attributeName=$sourceattribute sourceName=$sourcename } if ($transform.length -eq 0 -and $rule.Length -eq 0){ $attributeTransform=[pscustomobject]@{ attributeName=$identityattributename attributes=$accountattribute type='accountAttribute' } }elseif($rule.length -eq 0){ $input=[pscustomobject]@{ attributes=$accountattribute type='accountAttribute' } $attributes=[pscustomobject]@{ id=$transform input=$input } $attributeTransform=[pscustomobject]@{ attributename=$identityattributename attributes=$attributes type='reference' } }else{#create rule element } return $attributeTransform } |