Skip to content

Commit 353f314

Browse files
committed
Update to Get-TaskDetail and Set-PowerShell-Format
1 parent 26cf028 commit 353f314

4 files changed

Lines changed: 15 additions & 7 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# bretty.me.uk Defined
22

3-
# Local Testing for XML File Generation
3+
# Local Testing for XML File Generation and Local PS1 File Testing
44
*.xml
5+
*.ps1
56

67
#VSCode
78

CitrixOptimizerAutomation/Private/Get-TaskDetail.ps1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,25 @@ begin {
4141
process {
4242

4343
# Trim any Trailing \ chatacters
44-
$TaskTrimmed = $TaskPath.Substring(0,$TaskPath.Length - 1)
44+
if($TaskPath -notmatch '\\$'){
45+
$TaskTrimmed = $TaskPath.Substring(0,$TaskPath.Length)
46+
} else {
47+
$TaskTrimmed = $TaskPath.Substring(0,$TaskPath.Length - 1)
48+
}
4549

50+
if(!($TaskTrimmed.StartsWith("\"))){
51+
$TaskTrimmed = "\$($TaskTrimmed)"
52+
}
53+
4654
# Get The Task Name
4755
$TaskName = $TaskTrimmed.Substring($TaskTrimmed.lastIndexOf('\') + 1)
4856

4957
# Get The Task Path
50-
$TaskPath = $TaskTrimmed.Substring(0,$TaskTrimmed.lastIndexOf('\') + 1)
58+
$TaskPathReturn = $TaskTrimmed.Substring(0,$TaskTrimmed.lastIndexOf('\') + 1)
5159

5260
# Build the Return Object
5361
$Return | Add-Member -MemberType NoteProperty -Name "TaskName" -Value $TaskName
54-
$Return | Add-Member -MemberType NoteProperty -Name "TaskPath" -Value $TaskPath
62+
$Return | Add-Member -MemberType NoteProperty -Name "TaskPath" -Value $TaskPathReturn
5563

5664
} # process
5765

CitrixOptimizerAutomation/Private/Set-PowerShellFormat.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ process {
4747
}
4848

4949
# Add the true return value
50-
$FormattedScript = $FormattedScript + "`t`t" + '$Global' + ":CTXOE_Details = " + "Complete;`n"
50+
$FormattedScript = $FormattedScript + "`t`t" + '$Global' + ":CTXOE_Details = " + """Complete"";`n"
5151
$FormattedScript = $FormattedScript + "`t`t" + '$Global' + ":CTXOE_Result = " + '$True;' + "`n"
5252
$FormattedScript = $FormattedScript + "`t} catch {`n"
5353

5454
# Add the false return value
55-
$FormattedScript = $FormattedScript + "`t`t" + '$Global' + ":CTXOE_Details = " + "Errored;`n"
55+
$FormattedScript = $FormattedScript + "`t`t" + '$Global' + ":CTXOE_Details = " + """Errored"";`n"
5656
$FormattedScript = $FormattedScript + "`t`t" + '$Global' + ":CTXOE_Result = " + '$False;' + "`n"
5757
$FormattedScript = $FormattedScript + "`t}`n"
5858

CitrixOptimizerAutomation/Public/New-CitrixTemplateScript.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ process {
142142

143143
# Write the PowerShell Formatted Script
144144
$ParamValue = $XMLFile.CreateElement("value")
145-
$ParamValue.InnerText = $FinalScript
146145
$ParamValue.AppendChild($XMLFile.CreateCDataSection($FinalScript))
147146
$Params.AppendChild($ParamValue)
148147

0 commit comments

Comments
 (0)