Skip to content

Instantly share code, notes, and snippets.

@darrenjrobinson darrenjrobinson/Import.ps1 Secret
Created Jan 24, 2019

Embed
What would you like to do?
Microsoft Identity Manager PowerShell Management Agent for SailPoint IdentityNow Governance Groups
param (
$Username,
$Password,
$Credentials,
$OperationType,
[bool] $usepagedimport,
$pagesize
)
$DebugFilePath = "C:\PROGRA~1\MICROS~2\2010\SYNCHR~1\EXTENS~2\SailPo~1\Debug\IDNImport.txt"
if (!(Test-Path $DebugFilePath)) {
$DebugFile = New-Item -Path $DebugFilePath -ItemType File
}
else {
$DebugFile = Get-Item -Path $DebugFilePath
}
"Starting Import as : " + $OperationType + " - " + (Get-Date) | Out-File $DebugFile -Append
"Paged Import : " + $usepagedimport | Out-File $DebugFile -Append
"PageSize : " + $pagesize | Out-File $DebugFile -Append
# IdentityNow Orgname
$orgname = "myIDNOrgName"
# URI's
$baseURI = "https://$($orgName).api.identitynow.com"
# Basic Auth
$Bytes = [System.Text.Encoding]::utf8.GetBytes("$($Username):$($Password)")
$encodedAuth = [Convert]::ToBase64String($Bytes)
if (!$global:tenantObjects) {
# *********************** DELTA IMPORT **********************************
# Get Governance Groups
"Retreiving Governance Groups from SailPoint IdentityNow" | Out-File $DebugFile -Append
$GovGroups = Invoke-RestMethod -Method Get -Uri "$($baseURI)/v2/workgroups?&org=$($orgName)" -Headers @{Authorization = "Basic $($encodedAuth)"}
"$($GovGroups.Count) groups found" | Out-File $DebugFile -Append
# Counter to know where we are up to processing the Import
# Starting at minus 1 as our first object is 0 and I'm incrementing at the start of the loop.
[int]$global:objectsImported = -1
# An Array for the retuned objects to go into
$global:tenantObjects = @()
# Add in our first objects
$global:tenantObjects += $GovGroups
# Set last object ID
$global:lastsourceObjectID = "randomstring"
}
# ********************* Process Governance Groups into the MA *******************
[int]$objectpagecount = 0
foreach ($global:GovGroup in $global:tenantObjects) {
$global:gGroup = $global:tenantObjects[$global:objectsImported + 1]
if (!$global:gGroup -or ($global:objectsImported + 1 -eq $global:tenantObjects.count)) {
# nothing left to process
$global:MoreToImport = $false
break
}
if ($global:gGroup.id) {
$obj = @{}
$obj.Add("id", $global:gGroup.id)
$obj.Add("objectClass", "GovernanceGroup")
$obj.Add("description", $global:gGroup.description)
$obj.Add("name", $global:gGroup.name)
$obj.Add("memberCount", $global:gGroup.memberCount)
$obj.Add("ownerDisplayName", $global:gGroup.owner.displayName)
$obj.Add("ownerEmail", $global:gGroup.owner.emailAddress)
$obj.Add("ownerId", $global:gGroup.owner.id)
$obj.Add("ownerName", $global:gGroup.owner.name)
"Governance Group: " + $global:gGroup.description | Out-File $DebugFile -Append
# Pass the User Object to the MA
$obj
$objectpagecount++
$global:objectsImported++
"Paged Import User count: " + $objectpagecount | Out-File $DebugFile -Append
"Objects Imported count: " + $global:objectsImported | Out-File $DebugFile -Append
"Objects Remaining count: " + ($global:tenantObjects.count - $global:objectsImported - 1) | Out-File $DebugFile -Append
if ($objectpagecount -eq $pagesize) {
$global:MoreToImport = $true
"More to Import: " + $objectpagecount | Out-File $DebugFile -Append
break
}
}
}
# ***********************************************************
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.