The XA 65 Report Script

Posted: December 22, 2013 in Citrix
Tags: , , , , , , , , ,

Here’s the script to build the report from the previous script that gathered the data.

# Name: Get-DRFExternalAppAccess.ps1
# Author: David Figueroa
# Date: 12/2/2013
# Purpose: An automated script to enumerate the access to the external applications and produce a usable report describing this data.
# Credits:
# I wrote the XML document using this article =
#Load the Assembly
[System.Reflection.Assembly]::LoadWithPartialName("") | Out-Null
$FileOpen = New-Object System.Windows.Forms.OpenFileDialog
$FileOpen.Filter = 'XML Files (*.xml)|*.xml'
$FileOpen.FilterIndex = 2
$FileOpen.MultiSelect = $False
$FileOpen.SupportMultiDottedExtensions = $True
$FileOpen.Title = "Select the XML report from Get-DRFXAInformation.ps1"
if ($FileOpen.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {
[xml]$xml = New-Object -TypeName XML
} else {
#Create a temporary HTML file
$HTMLtemp = $env:TEMP + "\CTX" + (Get-Random -Maximum 99999).ToString() + ".htm"
# if the file exists, delete it, since it is a temp file :-)
if (Test-Path $HTMLTemp) {
Remove-Item -Path $HTMLtemp
#Build the HTML header for the report
Add-Content -Path $HTMLtemp -Value "<!DOCTYPE html>`r`n"
Add-Content -Path $HTMLtemp -Value "<html lang='en-US'>`r`n"
Add-content -Path $HTMLtemp -Value "<head>`r`n"
#CSS information
Add-Content -Path $HTMLtemp -Value "<style>s`r`n"
Add-Content -Path $HTMLTemp -Value "body { font-family:Verdana;font-size:10pt;color:blue}`r`n"
Add-Content -Path $HTMLTemp -Value "th {font-family:Verdana;font-size:11pt;color:blue}`r`n"
Add-Content -Path $HTMLTemp -Value "td {font-family:Verdana;font-size:10pt;color:blue}`r`n"
Add-Content -Path $HTMLtemp -Value "p {font-family:Verdana;font-size:14pt;color:blue}`r`n"
Add-Content -Path $HTMLtemp -Value "</style>`r`n"
Add-Content -Path $HTMLTemp -Value "<title>External Application Access Report</title>`r`n"
Add-Content -Path $HTMLtemp -Value "</head>`r`n"
Add-Content -Path $HTMLtemp -Value "<body>`r`n"
Add-Content -Path $HTMLTemp -Value "<p>External Application Access Report</p>`r`n"
Add-Content -Path $HTMLtemp -Value "<table border='1'>`r`n"
#Get the folders from the XML file
$xml.Folders.ChildNodes | Where-Object {$_.AppFolder -ilike "*external*"} | foreach {
$Folder = $_
#Write a header row for the Folder name
Add-Content -Path $HTMLtemp -Value ("<th colspan='3'>" + $Folder.AppFolder + "</th>`r`n")
#Start enumerating the applications
$Apps = $Folder.ChildNodes
#Now write a header row
Add-Content -Path $HTMLtemp -Value "<tr>`r`n"
Add-content -path $HTMLTemp -Value "<th width=25%;border=1px><strong>Application Name</strong></td>`r`n"
Add-content -path $HTMLTemp -Value "<th width=20%;border=1px><strong>Assigned Users</strong></td>`r`n"
Add-content -path $HTMLTemp -Value "<th width=55%;border=1px><strong>Assigned Group Users</strong></td>`r`n"
Add-Content -Path $HTMLtemp -Value "</tr>"
#Now process each of the apps
foreach ($app in $Apps) {
$TRString = "<tr>`r`n"
$TRString = $TRString + "<td>" + ($App.DisplayName) + "<br>" + ($app.FolderPath) + "</td>`r`n"
$TRString = $TRString + "<td>" + ($App.User -join ",") + "</td>`r`n"
$TRString = $TRString + "<td>`r`n"
foreach ($group in $app.Group) {
$TRString = $TRString + "<strong>[" + ($group.GroupName) + "]</strong><br>`r`n"
$TRString = $TRString + ($group.GroupUser -join ",") + "`r`n"
$TRString = $TRString + "<br>`r`n"
$TRString = $TRString + "</td>`r`n"
$TRString = $TRString + "</tr>`r`n"
Add-Content -Path $HTMLtemp -Value $TRString
} #Close foreach ($app in $apps)
} #close foreach( folders.childnodes)
Add-Content -Path $HTMLtemp -Value "</table>`r`n"
Add-Content -Path $HTMLtemp -Value "</body>`r`n"
#Load the XML file
$FileSave = New-Object System.Windows.Forms.SaveFileDialog
$FileSave.AddExtension = $true
$FileSave.AutoUpgradeEnabled = $true
$FileSave.CheckPathExists = $true
$FileSave.CreatePrompt = $true
$FileSave.DefaultExt = 'htm'
$FileSave.Filter = 'HTML Files (*.htm)|*.htm'
$FileSave.FilterIndex = 2
#$FileSave.InitialDirectory = [Environment]::GetFolderPath('MyDocuments')
$FileSave.OverwritePrompt = $true
$FileSave.ShowHelp = $false
$FileSave.SupportMultiDottedExtensions = $true
$FileSave.Title = 'Save the External Application Access report...'
$FileSave.ValidateNames = $true
$FileSave.FileName = 'ServerFarm_ExternalApplicationAccess_Report'
$FileSave.RestoreDirectory = $true
if ($FileSave.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {
Copy-Item -Path $HTMLtemp -Destination $FileSave.FileName
Remove-Item -Path $HTMLtemp
} else {


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s