I've created a powershell script that will compare Citrix Webinterface files then export them out to a csv file.
#***************************************************************************************************************
#* Created by: Trentent Tye
#* Intel Server Team
#* IBM Canada Ltd.
#*
#* Creation Date: Jul 17, 2013
#*
#* File Name: parse-webinterfaceconf.ps1
#*
#* Description: This script will generate a CSV file of all the webinterface.conf files that you copy into
#* the same folder as this script. For the purposes of our uses I have renamed the .conf files
#* to %URL%.conf. This script will take the file name of the conf files to use as the CSV
#* headers then go through that file and compare if the uncommented values exist as compared
#* to the master "values.txt" file. The "Values.txt" file was generated by taking the numerous
#* WebInterface files and deleting all lines that start with "#" and then removing duplicates
#* of all the values that were left. For the 3 .confs I started with there are 160 values
#* amoung all three that have had a value set.
#*
#*
#***************************************************************************************************************
$dirlist = Get-ChildItem -filter *.conf | Select-Object -ExpandProperty Name
#header value in powershell "Import-CSV" must be an array, a text variable parses as one header item
$header = @()
$header += "Value"
foreach ($item in $dirlist) {
$header += $item
}
#import csv with our header
$values = import-csv Values.txt -Header $header
#do a foreach item in Values append the matching value in the other .conf files
foreach ($item in $values) {
#check to see if the "Value" matches an item in the $dirlist and add that property in that file
foreach ($diritem in $dirlist) {
#get the webinterface.conf file
get-content $diritem | Foreach-Object {
#check to see if one of the values in the "Value" file matches one of the values in the file that is NOT commented out
if ($_.StartsWith($item.Value)) {
#get the value to the right of the equal sign
$pos = $_.IndexOf("=")
$rightPart = $_.Substring($pos+1)
#set the value to the appropriate column in the CSV
$item.$diritem = $rightPart
}
}
}
}
$values | Export-CSV complete.csv -NoTypeInformation -force
3 comments:
This is awesome!!! Thanks for sharing!
Glad you found it useful :)
Thanks for sharing:)
Very Informative Blog..!!
Regards
Custom citrix web interface
Post a Comment