Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SailPoint IdentityNow Email Templates Configuration Report. Associated blog post https://blog.darrenjrobinson.com/sailpoint-identitynow-email-templates-configuration-report/
# Document IdentityNow Email Templates Configuration
import-module SailPointIdentityNow
Get-IdentityNowOrg
Set-IdentityNowOrg -orgName 'yourOrgName'
$orgName = (Get-IdentityNowOrg).'Organisation Name'
$utime = [int][double]::Parse((Get-Date -UFormat %s))
# Get All Notification Templates
$getEmailTemplate = Invoke-IdentityNowRequest -uri "https://$($orgName).api.identitynow.com/cc/api/emailTemplate/list?_dc=$($utime)&filter=%7Bproperty%3A%20%22name%22%2C%20operation%3A%20%22EQ%22%2C%20value%3A%22Pending%20Access%20Request%20Cancelled%22%7D" -method get -headers Headersv3_JSON
$reportImagePath = "C:\Reports\SailPoint IdentityNow 240px.png"
$ReportOutputPath = "C:\Reports\IdentityNowConfigReports"
try {
$ImageData = [Convert]::ToBase64String((Get-Content $reportImagePath -Encoding Byte))
$ImageFile = Get-Item $reportImagePath
$ImageType = $ImageFile.Extension.Substring(1) #strip off the leading .
$ImageTag = "<Img src='data:image/$ImageType;base64,$($ImageData)' Alt='$($ImageFile.Name)' width='240' height='82' hspace=10>"
}
catch {
Write-Error "Report Image Path/Filename not found"
break
}
$reportDate = get-date -format "dd-MMM-yyyy HH-mm"
# Create Folder for Output in Path provided above with Report Date
$dir = "$($ReportOutputPath)\$($reportDate)"
if (!(Test-Path -Path $dir )) {
New-Item -ItemType directory -Path $dir
}
# Build up the HTML Report
$htmlFragments = @()
# Headings and Title
$top = @"
<center>
<h1>SailPoint IdentityNow Email Templates Configuration Report</h1>
<h2>Organisation - `'$($orgName.ToUpper())`'</h2>
<h3>`'$($getEmailTemplate.count)`' Notification Templates found<h3>
<b><center>$ImageTag</center></b>
</center>
"@
$htmlFragments += $top
$h2Text = "IdentityNow Notifications Configuration"
$div = $h2Text.Replace(" ", "_")
$htmlFragments += "<center><a href='javascript:toggleDiv(""$div"");' title='click to collapse or expand this section'><h2>$h2Text</h2></a><div id=""$div""><a href='javascript:toggleAll();' title=' Click to toggle all sections'>+ / -</a></center>"
# Build the HTML Report with Notification Templates
if ($getEmailTemplate.items) {
foreach ($eTemplate in $getEmailTemplate.items) {
Write-host -ForegroundColor Blue " Retrieved $($eTemplate.name) Template Configuration"
# Output template to File
$eTemplate | Export-Clixml -Path "$($dir)\$($orgName)-$($eTemplate.name)-Details-$($reportDate).xml"
# Template Details
$H3Text = "$($eTemplate.name) Details"
$div = $H3Text.Replace(" ", "_")
$htmlFragments += "<a href='javascript:toggleDiv(""$div"");' title='click to collapse or expand this section'><center><h4>$H3Text</h4></center></a><div id=""$div"" style=""display: none;"">"
$htmlFragments += "<center>"
$attrObjects = $eTemplate | Get-Member | Where-Object { $_.Definition.contains("Object[]") } | Select-Object
foreach ($attrObj in $attrObjects) {
$attrName = $attrObj.name
$eTemplate.$attrName = $eTemplate.$attrName | convertto-json
}
$htmlFragments += $eTemplate | ConvertTo-Html -As LIST
$htmlFragments += "</center>"
$htmlFragments += "</div>"
}
}
# Footer
$htmlFragments += "<center><p class='footer'>Report Generated $($reportDate)</p></center>"
# Header
$head = @"
<Title>SailPoint IdentityNow Email Notification Templates Report - $($orgName.ToUpper())</Title>
<style>
body {background-color:#ffffff; font:70%/1.5em Lato,sans-serif; padding:10px }
td,th {padding-left:8px}
th {color:black; background-color:cornflowerblue;}
table {border-spacing:1px; border-collapse:collapse; background:#F7F6F6; border-radius:6px; overflow:hidden; max-width:480px; width:70%; margin:0 auto; position:relative;}
table, tr, td, th {padding: 10px; margin: 0px ;white-space:pre; word-break:break-all; width:70%;}
tr:nth-child(even) {background-color:#dae5f4;}
tr:nth-child(odd) {background:#b8d1f3;}
thead tr {height:60px;background:#367AB1;color:#F5F6FA;font-size:1.2em;font-weight:700;text-transform:uppercase}
tbody tr {height:35px;border-bottom:1px solid #367AB1; word-break:break-all; text-transform:capitalize; font-size:1em;}
h1 {font-family:Tahoma;color:#A9A9A9;}
h2 {font-family:Tahoma;color:#6D7B8D;}
h3 {font-family:Tahoma;color:#6D7B8D;}
.alert {color: red;}
.footer {color:green; margin-left:10px; font-family:Tahoma; font-size:8pt; font-style:italic;}
.transparent {background-color:#ffffff;}
</style>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js'>
</script>
<script type='text/javascript'>
function toggleDiv(divId) {
`$("#"+divId).toggle();
}
function toggleAll() {
var divs = document.getElementsByTagName('div');
for (var i = 0; i < divs.length; i++) {
var div = divs[i];
`$("#"+div.id).toggle();
}
}
</script>
"@
# Output the Report
$convertParams = @{
head = $head
body = $htmlFragments
}
convertto-html @convertParams | out-file -FilePath "$($dir)\$($orgName)-EmailTemplateReport-$($reportDate).html"
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.