Skip to content

Commit c27d5b3

Browse files
committed
Update to commenting and verbose logging
1 parent 778f597 commit c27d5b3

18 files changed

Lines changed: 183 additions & 49 deletions

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,5 @@ If applicable, add screenshots to help explain your problem.
2828
- Browser [e.g. chrome, safari]
2929
- Version [e.g. 22]
3030

31-
**Smartphone (please complete the following information):**
32-
- Device: [e.g. iPhone6]
33-
- OS: [e.g. iOS8.1]
34-
- Browser [e.g. stock browser, safari]
35-
- Version [e.g. 22]
36-
3731
**Additional context**
3832
Add any other context about the problem here.

.gitignore

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,49 @@
1+
# bretty.me.uk Defined
2+
3+
# Local Testing for XML File Generation
14
*.xml
5+
6+
#VSCode
7+
8+
# vscode General
9+
.vscode/*
10+
!.vscode/settings.json
11+
!.vscode/tasks.json
12+
!.vscode/launch.json
13+
!.vscode/extensions.json
14+
!.vscode/*.code-snippets
15+
16+
# Local History for Visual Studio Code
17+
.history/
18+
19+
# Built Visual Studio Code Extensions
20+
*.vsix
21+
22+
# Mac OS
23+
24+
# General
25+
.DS_Store
26+
.AppleDouble
27+
.LSOverride
28+
29+
# Icon must end with two \r
30+
Icon
31+
32+
# Thumbnails
33+
._*
34+
35+
# Files that might appear in the root of a volume
36+
.DocumentRevisions-V100
37+
.fseventsd
38+
.Spotlight-V100
39+
.TemporaryItems
40+
.Trashes
41+
.VolumeIcon.icns
42+
.com.apple.timemachine.donotpresent
43+
44+
# Directories potentially created on remote AFP share
45+
.AppleDB
46+
.AppleDesktop
47+
Network Trash Folder
48+
Temporary Items
49+
.apdisk

CitrixOptimizerAutomation/CitrixOptimizerAutomation.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Module manifest for module 'Nutanix.Prism.Central'
2+
# Module manifest for module 'CitrixOptimizerAutomation'
33
#
44
# Generated by: David Brett
55
#
@@ -101,7 +101,7 @@ PrivateData = @{
101101
LicenseUri = 'https://github.com/dbretty/CitrixOptimizer/blob/main/LICENSE'
102102

103103
# A URL to the main website for this project.
104-
ProjectUri = 'https://bretty.me.uk/CitrixOptimizer'
104+
ProjectUri = 'https://bretty.me.uk/citrixoptimizerautomation'
105105

106106
# A URL to an icon representing this module.
107107
# IconUri = ''

CitrixOptimizerAutomation/CitrixOptimizerAutomation.psm1

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
<# INSERT HEADER ABOVE #>
2-
3-
#Get public and private function definition files.
4-
51
#Requires -Version 5.1
62

73
$Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue )
@@ -21,5 +17,4 @@ Foreach($import in @($Public + $Private))
2117
}
2218
}
2319

24-
Export-ModuleMember -Function $Public.Basename
25-
<# INSERT FOOTER BELOW #>
20+
Export-ModuleMember -Function $Public.Basename

CitrixOptimizerAutomation/Private/Get-TaskDetail.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function Get-TaskDetail {
1616
Returns a custom PSObject with the Path and TaskName values
1717
1818
.EXAMPLE
19-
PS> Get-TaskDetail TaskPath '/Microsoft/Windows/AppID'
19+
PS> Get-TaskDetail -TaskPath '/Microsoft/Windows/AppID'
2020
Decodes the Task Path passed in to a Task Path and Task Name.
2121
#>
2222

@@ -57,6 +57,7 @@ process {
5757

5858
end {
5959

60+
# Pass back return object
6061
return $Return
6162

6263
} # end

CitrixOptimizerAutomation/Private/Get-Template.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
function Get-Template {
22
<#
33
.SYNOPSIS
4-
Checks if a template already exists.
4+
Checks if a Citrix Optimizer template already exists.
55
66
.DESCRIPTION
7-
This function will take in a template file path and check if that template already exists.
7+
This function will take in a Citrix Optimizer template file path and check if that template already exists.
88
99
.PARAMETER Path
1010
Specifies the Path to the template file
@@ -13,7 +13,7 @@ function Get-Template {
1313
This function will take inputs via pipeline as string
1414
1515
.OUTPUTS
16-
Returns true or false base on the result of the template lookup
16+
Returns true or false base on the result of the Citrix Optimizer template lookup
1717
1818
.EXAMPLE
1919
PS> Get-Template -Path 'template.xml'
@@ -37,12 +37,14 @@ begin {
3737

3838
process {
3939

40+
# Check for the existence of the template file
4041
$Return = Test-Path $Path
4142

4243
} # process
4344

4445
end {
4546

47+
# Pass back return object
4648
return $Return
4749

4850
} # end

CitrixOptimizerAutomation/Private/Get-TemplateEntry.ps1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
function Get-TemplateEntry {
22
<#
33
.SYNOPSIS
4-
Checks if a template entry already exists.
4+
Checks if a template <entry> already exists.
55
66
.DESCRIPTION
7-
This function will take in a template file path and entry name check if the entry already exists.
7+
This function will take in a template file path and entry name check if the <entry> already exists.
88
99
.PARAMETER Path
1010
Specifies the XML template path
@@ -16,7 +16,7 @@ function Get-TemplateEntry {
1616
This function will take inputs via pipeline as string
1717
1818
.OUTPUTS
19-
Returns true or false base on the result of the template group lookup
19+
Returns true or false base on the result of the template entry lookup
2020
2121
.EXAMPLE
2222
PS> Get-TemplateEntry -Path $Path -EntryName 'Disable Print Spooler'
@@ -44,16 +44,23 @@ begin {
4444

4545
process {
4646

47+
# Set the default return value
4748
$Return = $false
49+
50+
# Get the contents of the XML file passed in
4851
[XML]$xmlentries = Get-Content $Path
4952

53+
# Check if there are no entries yet and return false
5054
if(($xmlentries.SelectNodes("/root//group//entry")).Count -eq 0){
5155
$Return = $false
5256
} else {
57+
# Get the entry name details from the XML variable
5358
$Entries = $xmlentries.SelectNodes("/root//group//entry") | where-object {$_.name -eq $($EntryName)}
5459
if($Null -eq $Entries){
60+
# Entry not found, return false
5561
$Return = $false
5662
} else {
63+
# Entry already in XML variable, return true
5764
$Return = $true
5865
}
5966
}
@@ -62,6 +69,7 @@ process {
6269

6370
end {
6471

72+
# Pass back return object
6573
return $Return
6674

6775
} # end

CitrixOptimizerAutomation/Private/Get-TemplateGroup.ps1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
function Get-TemplateGroup {
22
<#
33
.SYNOPSIS
4-
Checks if a template group already exists.
4+
Checks if a template <group> already exists.
55
66
.DESCRIPTION
7-
This function will take in a template file path and group name check if the group already exists.
7+
This function will take in a template file path and group name check if the <group> already exists.
88
99
.PARAMETER Path
1010
Specifies the XML template path
@@ -19,7 +19,7 @@ function Get-TemplateGroup {
1919
Returns true or false base on the result of the template group lookup
2020
2121
.EXAMPLE
22-
PS> Get-TemplateGroup -Path $xmlFile.path -GroupName 'Group1'
22+
PS> Get-TemplateGroup -Path 'template.xml' -GroupName 'Group1'
2323
Checks for 'Group1' in template.xml.
2424
#>
2525

@@ -44,15 +44,22 @@ begin {
4444

4545
process {
4646

47+
# Set the default return value
4748
$Return = $false
49+
50+
# Get the contents of the XML file passed in
4851
[XML]$xmlgroups = Get-Content $Path
4952

53+
# Check if there are no groups yet and return false
5054
if(($xmlgroups.SelectNodes("/root//group")).Count -eq 0){
5155
$Return = $false
5256
} else {
57+
# Get the group name details from the XML variable
5358
if($null -eq ($xmlfile.root.group | where-object {$_.id -eq $($GroupName)})){
59+
# Group not found, return false
5460
$Return = $false
5561
} else {
62+
# Group already in XML variable, return true
5663
$Return = $true
5764
}
5865
}
@@ -61,6 +68,7 @@ process {
6168

6269
end {
6370

71+
# Pass back return object
6472
return $Return
6573

6674
} # end

CitrixOptimizerAutomation/Public/New-CitrixTemplate.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,16 @@ begin {
6969

7070
process {
7171

72+
# Check if the template already exists
7273
if(!(Get-Template -Path $Path)){
7374

74-
# Set The Formatting
75+
# Set the XML Formatting
7576
write-verbose "Set the XML formatting"
7677
$xmlsettings = New-Object System.Xml.XmlWriterSettings
7778
$xmlsettings.Indent = $true
7879
$xmlsettings.IndentChars = " "
7980

80-
# Set the File Name Create The Document
81+
# Set the XML File Name Create The Document
8182
write-verbose "Create Base XML Template for Citrix Optimizer"
8283
$XmlWriter = [System.XML.XmlWriter]::Create($Path, $xmlsettings)
8384

@@ -91,7 +92,7 @@ process {
9192
$xmlWriter.WriteAttributeString("xmlns", "xsi", $null, "http://www.w3.org/2001/XMLSchema-instance")
9293

9394
# Start the Metadata Element
94-
write-verbose "Write metadata element for Citrix Optimizer Template"
95+
write-verbose "Write metadata element for the Citrix Optimizer Template"
9596
$xmlWriter.WriteStartElement("metadata")
9697

9798
# Write Metadata details
@@ -137,7 +138,7 @@ process {
137138

138139
end {
139140

140-
# Return result
141+
# Add the template path and pass back return object
141142
$Return | Add-Member -MemberType NoteProperty -Name "Path" -Value $Path
142143
return $Return
143144

CitrixOptimizerAutomation/Public/New-CitrixTemplateGroup.ps1

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function New-CitrixTemplateGroup {
44
Creates a new Group in the Citrix Optimizer template.
55
66
.DESCRIPTION
7-
This function will create a Group in the Citrix Optimizer template. First it will check if that group exists, if not it will add it.
7+
This function will create a Group in the Citrix Optimizer template. First it will check if that <group> exists, if not it will add it.
88
99
.PARAMETER Path
1010
Specifies the Path to the template file
@@ -62,6 +62,7 @@ begin {
6262

6363
process {
6464

65+
# Check if the template already exists
6566
if(Get-Template -Path $Path){
6667

6768
write-verbose "Citrix Optimizer Template $($Path) found"
@@ -70,44 +71,53 @@ process {
7071
# Load Template and check for existing Group"
7172
[XML]$xmlfile = Get-Content $Path
7273

74+
# Check that the template group does not exist
7375
if(!(Get-TemplateGroup -Path $Path -GroupName $GroupName)){
7476

7577
write-verbose "No existing Groups found, adding new group"
7678

79+
# Create the Group element
7780
write-verbose "Create Group element"
7881
$Group = $XMLFile.CreateElement("group")
7982

83+
# Create the ID element
8084
write-verbose "Create ID element"
8185
$ID = $XMLFile.CreateElement("id")
8286
$ID.InnerText = $GroupName
8387
$Group.AppendChild($ID)
8488

89+
# Create the display name element
8590
write-verbose "Create DisplayName element"
8691
$Name = $XMLFile.CreateElement("displayname")
8792
$Name.InnerText = $GroupName
8893
$Group.AppendChild($Name)
8994

95+
# Create the description element
9096
write-verbose "Create Description element"
9197
$Description = $XMLFile.CreateElement("description")
9298
$Description.InnerText = $GroupDescription
9399
$Group.AppendChild($Description)
94100

101+
# Append the group ID element to the Group and save the XML file
95102
write-verbose "Add Group to Citrix Optimizer XML Template"
96103
$XMLFile.LastChild.AppendChild($Group)
97104
$XMLFile.Save($Path)
98105

106+
# Add the GroupName to the return object
99107
$Return | Add-Member -MemberType NoteProperty -Name "GroupName" -Value $GroupName
100108
$Return.Complete = $true
101109

102110
} else {
103-
111+
112+
# Group already exists
104113
write-verbose "Group $($GroupName) already exists - quitting"
105114
write-error "Group $($GroupName) already exists - quitting"
106115

107116
}
108117

109118
} else {
110119

120+
# Template file not found
111121
write-verbose "Citrix Optimizer Template $($Path) not found - quitting"
112122
write-error "Citrix Optimizer Template $($Path) not found - quitting"
113123

@@ -117,6 +127,7 @@ process {
117127

118128
end {
119129

130+
# Pass back return object
120131
return $Return
121132

122133
} # end

0 commit comments

Comments
 (0)