Skip to content

Commit 827ae70

Browse files
authored
Merge pull request #1 from dbretty/Enable-Advanced-Function-Options
Update to include State Parameter
2 parents 7a0f762 + 6476ce1 commit 827ae70

5 files changed

Lines changed: 64 additions & 22 deletions

File tree

CitrixOptimizerAutomation/Public/New-CitrixTemplateService.ps1

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,23 @@ function New-CitrixTemplateService {
2121
.PARAMETER GroupName
2222
The existing Group to add the Service to
2323
24+
.PARAMETER State
25+
The Service State (Enabled / Disabled)
26+
2427
.INPUTS
2528
This function will take inputs via pipeline as string
2629
2730
.OUTPUTS
2831
Returns $true or $false depending on the Service creation state
2932
3033
.EXAMPLE
31-
PS> New-CitrixTemplateService -Path 'template.xml' -EntryName 'Disable the Print Spooler' -ServiceName 'spooler' -ServiceDescription 'Windows Print Service' -GroupName 'Group 1'
34+
PS> New-CitrixTemplateService -Path 'template.xml' -EntryName 'Disable the Print Spooler' -ServiceName 'spooler' -ServiceDescription 'Windows Print Service' -GroupName 'Group 1' -State "Disabled"
3235
Adds an entry to disable the Print Spooler service in the template file.
3336
.EXAMPLE
34-
PS> New-CitrixTemplateService -Path $Template.Path -EntryName 'Disable the Print Spooler' -ServiceName 'spooler' -ServiceDescription 'Windows Print Service' -GroupName 'Group 1'
37+
PS> New-CitrixTemplateService -Path $Template.Path -EntryName 'Disable the Print Spooler' -ServiceName 'spooler' -ServiceDescription 'Windows Print Service' -GroupName 'Group 1' -State "Disabled"
3538
Adds an entry to disable the Print Spooler service in the template file passed in via the output from the New-CitrixTemplate cmdlet.
3639
.EXAMPLE
37-
PS> New-CitrixTemplateService -Path 'template.xml' -EntryName 'Disable the Print Spooler' -ServiceName 'spooler' -ServiceDescription 'Windows Print Service' -GroupName $Group.GroupName
40+
PS> New-CitrixTemplateService -Path 'template.xml' -EntryName 'Disable the Print Spooler' -ServiceName 'spooler' -ServiceDescription 'Windows Print Service' -GroupName $Group.GroupName -State "Disabled"
3841
Adds an entry to disable the Print Spooler service in the template file passed in via the output from the New-CitrixTemplate cmdlet and the Group Name passed in via the output $Group.GroupName.
3942
4043
.LINK
@@ -63,7 +66,12 @@ Param (
6366
[Parameter(
6467
ValuefromPipelineByPropertyName = $true,mandatory=$true
6568
)]
66-
[System.String]$GroupName
69+
[System.String]$GroupName,
70+
[Parameter(
71+
ValuefromPipelineByPropertyName = $true,mandatory=$true
72+
)]
73+
[ValidateSet("Enabled","Disabled")]
74+
$State
6775
)
6876

6977
begin {
@@ -127,7 +135,7 @@ process {
127135
$Params.AppendChild($ParamName)
128136

129137
$ParamValue = $XMLFile.CreateElement("value")
130-
$ParamValue.InnerText = "Disabled"
138+
$ParamValue.InnerText = $State
131139
$Params.AppendChild($ParamValue)
132140

133141
$Action.AppendChild($Params)

CitrixOptimizerAutomation/Public/New-CitrixTemplateTask.ps1

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,23 @@ function New-CitrixTemplateTask {
2121
.PARAMETER TaskDescription
2222
The Description for the Scheduled Task
2323
24+
.PARAMETER State
25+
The Service State (Enabled / Disabled)
26+
2427
.INPUTS
2528
This function will take inputs via pipeline as string
2629
2730
.OUTPUTS
2831
Returns $true or $false depending on the Scheduled Task creation state
2932
3033
.EXAMPLE
31-
PS> New-CitrixTemplateTask -Path 'template.xml' -GroupName 'Group1' -TaskName 'SchTask - AppID' -TaskPath '\Microsoft\Windows\AppID\' -TaskDescription 'This is the AppID Scheduled Task'
34+
PS> New-CitrixTemplateTask -Path 'template.xml' -GroupName 'Group1' -TaskName 'SchTask - AppID' -TaskPath '\Microsoft\Windows\AppID\' -TaskDescription 'This is the AppID Scheduled Task' -State "Disabled"
3235
Adds an entry to disable the AppID Scheduled Task in the template file.
3336
.EXAMPLE
34-
PS> New-CitrixTemplateTask -Path $Template.Path -GroupName 'Group1' -TaskName 'SchTask - AppID' -TaskPath '\Microsoft\Windows\AppID\' -TaskDescription 'This is the AppID Scheduled Task'
37+
PS> New-CitrixTemplateTask -Path $Template.Path -GroupName 'Group1' -TaskName 'SchTask - AppID' -TaskPath '\Microsoft\Windows\AppID\' -TaskDescription 'This is the AppID Scheduled Task' -State "Disabled"
3538
Adds an entry to disable the AppID Scheduled Task in the template file based on the return value in $Template.Path
3639
.EXAMPLE
37-
PS> New-CitrixTemplateTask -Path $Template.Path -GroupName $Group.Name -TaskName 'SchTask - AppID' -TaskPath '\Microsoft\Windows\AppID\' -TaskDescription 'This is the AppID Scheduled Task'
40+
PS> New-CitrixTemplateTask -Path $Template.Path -GroupName $Group.Name -TaskName 'SchTask - AppID' -TaskPath '\Microsoft\Windows\AppID\' -TaskDescription 'This is the AppID Scheduled Task' -State "Disabled"
3841
Adds an entry to disable the AppID Scheduled Task in the template file based on the return value in $Template.Path and $Group.Name
3942
4043
.LINK
@@ -63,7 +66,12 @@ Param (
6366
[Parameter(
6467
ValuefromPipelineByPropertyName = $true,mandatory=$true
6568
)]
66-
[System.String]$TaskDescription
69+
[System.String]$TaskDescription,
70+
[Parameter(
71+
ValuefromPipelineByPropertyName = $true,mandatory=$true
72+
)]
73+
[ValidateSet("Enabled","Disabled")]
74+
$State
6775
)
6876

6977
begin {
@@ -130,7 +138,7 @@ process {
130138
$Params.AppendChild($ParamPath)
131139

132140
$ParamValue = $XMLFile.CreateElement("value")
133-
$ParamValue.InnerText = "Disabled"
141+
$ParamValue.InnerText = $State
134142
$Params.AppendChild($ParamValue)
135143

136144
$Action.AppendChild($Params)

Examples/TestScript.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ New-CitrixTemplateGroup -Path $Template.Path -GroupName 'OS Optimizations' -Grou
1818
New-CitrixTemplateGroup -Path $Template.Path -GroupName 'HKLM Optimizations' -GroupDescription "HKLM Optimization Group"
1919

2020
# Create Service Entries
21-
New-CitrixTemplateService -Path $Template.Path -EntryName 'Disable the Print Spooler' -ServiceName 'spooler' -ServiceDescription 'Windows Print Service' -GroupName 'System Optimizations'
22-
New-CitrixTemplateService -Path $Template.Path -EntryName 'Disable the AppID Service' -ServiceName 'AppID' -ServiceDescription 'AppID Service' -GroupName 'System Optimizations'
23-
New-CitrixTemplateService -Path $Template.Path -EntryName 'Disable the Citrix Primt Management' -ServiceName 'CpSvc' -ServiceDescription 'Citrix Print Service' -GroupName 'System Optimizations'
21+
New-CitrixTemplateService -Path $Template.Path -EntryName 'Disable the Print Spooler' -ServiceName 'spooler' -ServiceDescription 'Windows Print Service' -GroupName 'System Optimizations' -State "Disabled"
22+
New-CitrixTemplateService -Path $Template.Path -EntryName 'Disable the AppID Service' -ServiceName 'AppID' -ServiceDescription 'AppID Service' -GroupName 'System Optimizations' -State "Disabled"
23+
New-CitrixTemplateService -Path $Template.Path -EntryName 'Disable the Citrix Primt Management' -ServiceName 'CpSvc' -ServiceDescription 'Citrix Print Service' -GroupName 'System Optimizations' -State "Disabled"
2424

2525
# Create Scheduled Task Entries
26-
New-CitrixTemplateTask -Path $Template.Path -GroupName 'System Optimizations' -TaskName 'SchTask - AppID' -TaskPath '\Microsoft\Windows\AppID\' -TaskDescription 'This is the AppID Scheduled Task'
27-
New-CitrixTemplateTask -Path $Template.Path -GroupName 'System Optimizations' -TaskName 'SchTask - OfficeUpdate' -TaskPath '\Microsoft\Windows\Office\Update\' -TaskDescription 'This is the Office Update Scheduled Task'
28-
New-CitrixTemplateTask -Path $Template.Path -GroupName 'System Optimizations' -TaskName 'SchTask - Microsoft Edge Update' -TaskPath '\Microsoft\Edge\Update\' -TaskDescription 'This is the Microsoft Edge Update Scheduled Task'
26+
New-CitrixTemplateTask -Path $Template.Path -GroupName 'System Optimizations' -TaskName 'SchTask - AppID' -TaskPath '\Microsoft\Windows\AppID\' -TaskDescription 'This is the AppID Scheduled Task' -State "Disabled"
27+
New-CitrixTemplateTask -Path $Template.Path -GroupName 'System Optimizations' -TaskName 'SchTask - OfficeUpdate' -TaskPath '\Microsoft\Windows\Office\Update\' -TaskDescription 'This is the Office Update Scheduled Task' -State "Disabled"
28+
New-CitrixTemplateTask -Path $Template.Path -GroupName 'System Optimizations' -TaskName 'SchTask - Microsoft Edge Update' -TaskPath '\Microsoft\Edge\Update\' -TaskDescription 'This is the Microsoft Edge Update Scheduled Task' -State "Disabled"
2929

Help/New-CitrixTemplateService.MD

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ New-CitrixTemplateService
1111
[-ServiceName] <String[]>
1212
[-ServiceDescription] <String[]>
1313
[-GroupName] <String[]>
14+
[-State] <String[]>
1415
[<CommonParameters>]
1516
```
1617
## Description
@@ -22,23 +23,23 @@ This function will create Service Definition in the Citrix Optimizer template.
2223
### Example 1
2324

2425
```PowerShell
25-
New-CitrixTemplateService -Path 'template.xml' -EntryName 'Disable the Print Spooler' -ServiceName 'spooler' -ServiceDescription 'Windows Print Service' -GroupName 'Group 1'
26+
New-CitrixTemplateService -Path 'template.xml' -EntryName 'Disable the Print Spooler' -ServiceName 'spooler' -ServiceDescription 'Windows Print Service' -GroupName 'Group 1' -State "Disabled"
2627
```
2728

2829
Adds an entry to disable the Print Spooler service in the template file.
2930

3031
### Example 2
3132

3233
```PowerShell
33-
New-CitrixTemplateService -Path $Template.Path -EntryName 'Disable the Print Spooler' -ServiceName 'spooler' -ServiceDescription 'Windows Print Service' -GroupName 'Group 1'
34+
New-CitrixTemplateService -Path $Template.Path -EntryName 'Disable the Print Spooler' -ServiceName 'spooler' -ServiceDescription 'Windows Print Service' -GroupName 'Group 1' -State "Disabled"
3435
```
3536

3637
Adds an entry to disable the Print Spooler service in the template file passed in via the output from the ```New-CitrixTemplate``` cmdlet.
3738

3839
### Example 3
3940

4041
```PowerShell
41-
New-CitrixTemplateService -Path 'template.xml' -EntryName 'Disable the Print Spooler' -ServiceName 'spooler' -ServiceDescription 'Windows Print Service' -GroupName $Group.GroupName
42+
New-CitrixTemplateService -Path 'template.xml' -EntryName 'Disable the Print Spooler' -ServiceName 'spooler' -ServiceDescription 'Windows Print Service' -GroupName $Group.GroupName -State "Disabled"
4243
```
4344

4445
Adds an entry to disable the Print Spooler service in the template file passed in via the output from the ```New-CitrixTemplate``` cmdlet and the Group Name passed in via the output $Group.GroupName.
@@ -97,6 +98,18 @@ Specifies the Service Description to add to the template
9798

9899
Specifies the Group to add the Service definition to
99100

101+
| Description | Option |
102+
|:---|:---|
103+
| Type | String |
104+
| Mandatory | True |
105+
| Default Value: | None |
106+
| Accept pipeline input: | True |
107+
| Accept wildcard characters: | False |
108+
109+
### -State
110+
111+
Specifies the Service State (Enabled/Disabled)
112+
100113
| Description | Option |
101114
|:---|:---|
102115
| Type | String |

Help/New-CitrixTemplateTask.MD

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ New-CitrixTemplateTask
1111
[-TaskName] <String[]>
1212
[-TaskPath] <String[]>
1313
[-TaskDescription] <String[]>
14+
[-State] <String[]>
1415
[<CommonParameters>]
1516
```
1617
## Description
@@ -22,23 +23,23 @@ This function will create a Scheduled Task Definition in the Citrix Optimizer te
2223
### Example 1
2324

2425
```PowerShell
25-
New-CitrixTemplateTask -Path 'template.xml' -Group 'Group1' -TaskName 'SchTask - AppID' -TaskPath '\Microsoft\Windows\AppID\' -TaskDescription 'This is the AppID Scheduled Task'
26+
New-CitrixTemplateTask -Path 'template.xml' -Group 'Group1' -TaskName 'SchTask - AppID' -TaskPath '\Microsoft\Windows\AppID\' -TaskDescription 'This is the AppID Scheduled Task' -State "Disabled"
2627
```
2728

2829
Adds an entry to disable the AppID Scheduled Task in the template file.
2930

3031
### Example 2
3132

3233
```PowerShell
33-
New-CitrixTemplateTask -Path $Template.Path -GroupName 'Group1' -TaskName 'SchTask - AppID' -TaskPath '\Microsoft\Windows\AppID\' -TaskDescription 'This is the AppID Scheduled Task'
34+
New-CitrixTemplateTask -Path $Template.Path -GroupName 'Group1' -TaskName 'SchTask - AppID' -TaskPath '\Microsoft\Windows\AppID\' -TaskDescription 'This is the AppID Scheduled Task' -State "Disabled"
3435
```
3536

3637
Adds an entry to disable the AppID Scheduled Task in the template file based on the return value in $Template.Path
3738

3839
### Example 3
3940

4041
```PowerShell
41-
New-CitrixTemplateTask -Path $Template.Path -GroupName $Group.Name -TaskName 'SchTask - AppID' -TaskPath '\Microsoft\Windows\AppID\' -TaskDescription 'This is the AppID Scheduled Task'
42+
New-CitrixTemplateTask -Path $Template.Path -GroupName $Group.Name -TaskName 'SchTask - AppID' -TaskPath '\Microsoft\Windows\AppID\' -TaskDescription 'This is the AppID Scheduled Task' -State "Disabled"
4243
```
4344

4445
Adds an entry to disable the AppID Scheduled Task in the template file based on the return value in $Template.Path and $Group.Name
@@ -97,6 +98,18 @@ The Full Path to the Scheduled Task
9798

9899
The Description for the Scheduled Task
99100

101+
| Description | Option |
102+
|:---|:---|
103+
| Type | String |
104+
| Mandatory | True |
105+
| Default Value: | None |
106+
| Accept pipeline input: | True |
107+
| Accept wildcard characters: | False |
108+
109+
### -State
110+
111+
Specifies the Service State (Enabled/Disabled)
112+
100113
| Description | Option |
101114
|:---|:---|
102115
| Type | String |

0 commit comments

Comments
 (0)