Skip to content
Open

V2 #3

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
df49655
add build.ps1 script to update module manifest
tonysathre Sep 12, 2024
6ad3036
add CitrixAutodeploy module
tonysathre Sep 12, 2024
0c53faa
add wip tests
tonysathre Sep 12, 2024
ecf29e7
full rewrite using new CitrixAutodeploy module
tonysathre Sep 12, 2024
fef0416
add script for running tests
tonysathre Sep 12, 2024
9a54fcb
add Invoke-CtxAdTask.ps1 and tests
tonysathre Sep 13, 2024
d862e03
remove file
tonysathre Sep 13, 2024
c8db115
update module manifest for new function Invoke-CtxAdTask
tonysathre Sep 13, 2024
34af87a
Import our module CitrixAutodeploy
tonysathre Sep 13, 2024
b011c37
change parameter type: string -> System.IO.FileInfo
tonysathre Sep 13, 2024
840043b
import our module CitrixAutodeploy
tonysathre Sep 13, 2024
5c5621a
update parameter order
tonysathre Sep 13, 2024
2c0548b
cleanup
tonysathre Sep 13, 2024
4bcbf4b
update tests
tonysathre Sep 13, 2024
05d3fd4
ignore .vscode/
tonysathre Oct 1, 2024
b29a855
move assets into assets/
tonysathre Oct 1, 2024
f2b0c8a
rename files
tonysathre Oct 1, 2024
bc8e2f8
update build script
tonysathre Oct 1, 2024
9ecceb2
wip
tonysathre Oct 1, 2024
cf0489e
wip
tonysathre Oct 1, 2024
3558a56
moved file
tonysathre Oct 1, 2024
73ca83c
fix tests
tonysathre Oct 1, 2024
2b47673
cleanup test files
tonysathre Oct 1, 2024
9b2d982
improve logging output
tonysathre Oct 2, 2024
13fe0af
simplify error handling
tonysathre Oct 2, 2024
891843c
prepend timestamp to log output
tonysathre Oct 2, 2024
84ef74c
enable code coverage reporting
tonysathre Oct 2, 2024
1f9be4f
don't delete temp files
tonysathre Oct 2, 2024
397acd2
fix tests
tonysathre Oct 2, 2024
da2fdac
fix path to task scripts
tonysathre Oct 2, 2024
bc881df
ignore pester code coverage report
tonysathre Oct 4, 2024
c8953a9
improve error messages
tonysathre Oct 4, 2024
aa75ae0
write all log messages to stdout in CI env
tonysathre Oct 4, 2024
75c39e7
wip
tonysathre Oct 4, 2024
6ac3536
Update Write-CitrixAutoDeployLog.Tests.ps1
tonysathre Oct 4, 2024
77ee720
add run.ps1
tonysathre Oct 5, 2024
ed9e334
replace function Write-CtxAutodeployLog with PoShLog
tonysathre Oct 7, 2024
77d721b
rename parameter: Task -> FilePath
tonysathre Oct 7, 2024
d771c7a
add function Initialize-CtxAutodeployLogger
tonysathre Oct 7, 2024
1e1a976
move files into module/CitrixAutodeploy/functions/public/
tonysathre Oct 8, 2024
c57b2fa
Restructure
tonysathre Oct 8, 2024
7de0497
update module manifest
tonysathre Oct 8, 2024
db4eb86
ignore log files
tonysathre Oct 8, 2024
f2689c1
don't wrap PropertyValues in single quotes
tonysathre Oct 8, 2024
bbd301a
add Logging parameter
tonysathre Oct 8, 2024
92f1ddb
add functions to start and stop logging in Citrix
tonysathre Oct 8, 2024
14b1426
update module manifest
tonysathre Oct 8, 2024
009fb9c
Merge pull request #5 from tonysathre/poshlog
tonysathre Oct 9, 2024
106c813
fix merge conflict
tonysathre Oct 9, 2024
a902651
Merge branch 'v2' of https://github.com/tonysathre/CitrixAutoDeploy i…
tonysathre Oct 9, 2024
51fb9b8
throw terminating error if file not found
tonysathre Oct 10, 2024
21f25fc
add function Test-DdcConnection
tonysathre Oct 11, 2024
b52a8d2
renamed file: Initialize-Environment.ps1 -> Initialize-CtxAutodeployE…
tonysathre Oct 11, 2024
4c67ca7
rename file: Initialize-Environment.Tests.ps1 Initialize-CtxAutodeplo…
tonysathre Oct 11, 2024
84fcab9
update tests
tonysathre Oct 11, 2024
cdc3a16
add tests for Test-DdcConnection.ps1
tonysathre Oct 11, 2024
3f202a1
output job details as json
tonysathre Oct 11, 2024
16d2616
use first ddc that passes Test-DdcConnection
tonysathre Oct 11, 2024
72471ee
add Test-DdcConnection
tonysathre Oct 11, 2024
7b5a0a3
Support specifying multiple delivery controllers
tonysathre Oct 11, 2024
d0bcc18
fix
tonysathre Oct 11, 2024
493a1f9
Merge branch 'v2' of https://github.com/tonysathre/CitrixAutoDeploy i…
tonysathre Oct 11, 2024
cc6471c
add MaxRecordCount parameter
tonysathre Oct 12, 2024
d2f0227
implement Test-MaxMachineCount
tonysathre Oct 12, 2024
62ed9c7
add function Test-MaxMachineCount
tonysathre Oct 12, 2024
8af4887
implement new parameters
tonysathre Oct 12, 2024
cd63d96
wip
tonysathre Oct 12, 2024
f1adbcf
rename file: Test-MaxMachineCount.ps1 -> Test-MachineCountLimit.ps1
tonysathre Oct 12, 2024
98298f4
add tests for Test-MachineCountLimit
tonysathre Oct 12, 2024
2561abe
update module manifest
tonysathre Oct 12, 2024
df7de97
update parameters
tonysathre Oct 12, 2024
92d0181
rename: Initialize-Environment -> Initialize-CtxAutodeployEnv
tonysathre Oct 12, 2024
5c8da90
checkpoint
tonysathre Oct 24, 2024
14ab9bb
update documentation
tonysathre Oct 24, 2024
216a1e3
final
tonysathre Oct 24, 2024
32fa9c8
cleanup
tonysathre Oct 24, 2024
5d2fa6c
change continue -> break
tonysathre Oct 31, 2024
e019bbf
remove $Logging variable when stopping the logger
tonysathre Oct 31, 2024
060ff50
update module manifest
tonysathre Oct 31, 2024
e13eff5
cleanup old code
tonysathre Oct 31, 2024
5fe255e
change debug message to warning
tonysathre Oct 31, 2024
8d8d3f9
rename: Test-MachineCountLimit -> Test-MachineCountExceedsLimit
tonysathre Oct 31, 2024
edaee53
update module manifest
tonysathre Oct 31, 2024
9407892
redirect unapproved verb warnings to $null
tonysathre Oct 31, 2024
6c0dc31
renamed: tests/Test-MachineCountLimit.Tests.ps1 -> tests/Test-Machine…
tonysathre Oct 31, 2024
3a3bcf9
update tests for Test-MachineCountExceedsLimit
tonysathre Oct 31, 2024
1ab2842
Merge pull request #10 from tonysathre/v2-max-machines
tonysathre Nov 1, 2024
5a9b2f4
Get tests working in CI (#14)
tonysathre Nov 26, 2024
85ce2f7
Fix flaky test in `Wait-ForIdentityPoolUnlock.Tests.ps1` (#19)
tonysathre Nov 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI

on:
pull_request:

jobs:
test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- run: .\install-prereqs.ps1 -Force
shell: powershell

- run: |
$env:PSModulePath += ";C:\Program Files\Citrix\PowerShellModules"
.\test
shell: powershell
Empty file added .github/workflows/lint.yml
Empty file.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ citrix_autodeploy_config.json
citrix_autodeploy_config_email.json
post-task/*
pre-task/*
.vscode/*

# pester code coverage report
coverage.xml
*.log
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The Active Directory service account will need the 'Machine Catalog Administrato
> I would not recommend running this directly on one of your delivery controllers. I run this on a management jump box.

Start Powershell as Administrator then run the following commands:

git clone https://github.com/tonysathre/CitrixAutoDeploy.git
cd CitrixAutoDeploy
.\setup.ps1
Expand Down Expand Up @@ -56,6 +56,8 @@ You will need to configure which machine catalogs and delivery groups you want t
"BrokerCatalog" : "Example Machine Catalog",
"DesktopGroupName" : "Example Delivery Group",
"MinAvailableMachines" : 1,
"MaxMachinesInDesktopGroup" : 0,
"MaxMachinesInBrokerCatalog" : 0,
"PreTask" : "",
"PostTask" : ""
}
Expand All @@ -64,16 +66,20 @@ You will need to configure which machine catalogs and delivery groups you want t
}
```

> You can disable a job by setting `MinAvailableMachines` to `0`
>
> You can disable `MaxMachinesInDesktopGroup` and `MaxMachinesInBrokerCatalog` by not including them in the job definition, or by setting the value to `0`

|Attribute|Description|
|--- | ---|
|AdminAddress | Delivery controller FQDN
|BrokerCatalog | Machine catalog name
|DesktopGroupName | Delivery group name
|MinAvailableMachines | How many machines you want to be available at all times
|PreTask | Script to run before creating a new machine
|PostTask | Script to run after creating a new machine

MinAvailableMachines works by checking how many **unassigned** machines there are in the delivery group. It then subtracts that number from MinAvailableMachines to determine how many machines it must create to satisfy the configured MinAvailableMachines.
|AdminAddress | Delivery controller FQDN |
|BrokerCatalog | Machine catalog name |
|DesktopGroupName | Delivery group name |
|MinAvailableMachines | How many machines you want to be available at all times |
|MaxMachinesInBrokerCatalog | Limit the number of machines that can be added to the catalog |
|MaxMachinesInDesktopGroup | Limit the number of machines that can be added to the desktop group |
|PreTask | Script to run before creating a new machine |
|PostTask | Script to run after creating a new machine |

### Adding custom properties

Expand All @@ -96,7 +102,7 @@ Then in your post-task script, you can reference your custom property using the
```powershell
if (![string]::IsNullOrEmpty($AutoDeployMonitor.ADGroups)) {
$ADObject = Get-AdComputer $NewBrokerMachine.MachineName.Split('\')[1]

foreach ($ADGroup in $AutoDeployMonitor.ADGroups) {
Add-ADGroupMember -Identity $ADGroup -Members $ADObject
}
Expand Down Expand Up @@ -136,7 +142,7 @@ $Fact2 = New-TeamsFact -Name 'Machine Catalog' -Value $MachineCatalog
$Fact3 = New-TeamsFact -Name 'Delivery Group' -Value $DeliveryGroup

$TeamsSection = @{
ActivityDetails = $Fact1, $Fact2, $Fact3
ActivityDetails = $Fact1, $Fact2, $Fact3
}

$Sections = New-TeamsSection @TeamsSection
Expand All @@ -154,7 +160,7 @@ Send-TeamsMessage @TeamsMessage

Here's an example MS Teams notification:

![MS Teams](./teams.png)
![MS Teams](./assets/teams.png)

The two included monitor scripts will send alerts for event ID's 1 and 3 by default. You can get additional alerts by creating scheduled tasks that trigger on the different event ID's described below.

Expand All @@ -177,7 +183,7 @@ You can define a script to run in the [`citrix_autodeploy_config.json`](citrix_a
Here is an example post-task that puts the newly created machine into maintenance mode, and then powers it on:

```powershell
Set-BrokerMachineMaintenanceMode -AdminAddress $AdminAddress -InputObject $NewBrokerMachine -MaintenanceMode $true
Set-BrokerMachineMaintenanceMode -AdminAddress $AdminAddress -InputObject $NewBrokerMachine -MaintenanceMode $true
New-BrokerHostingPowerAction -AdminAddress $AdminAddress -MachineName $NewBrokerMachine.MachineName -Action TurnOn
```
The following variables can be used in pre and post-task scripts:
Expand Down
File renamed without changes
34 changes: 34 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Remove-Module Microsoft.PowerShell.PSResourceGet -ErrorAction SilentlyContinue
Import-Module Microsoft.PowerShell.PSResourceGet -ErrorAction Stop

$Author = 'Tony Sathre'
$CompanyName = 'Tony Sathre'
$Description = 'This module is used to automate the deployment of Citrix virtual desktops in a Citrix Virtual Apps & Desktops environment.'
$ModuleVersion = '2.0.0.0'
$Copyright = "(c) {0} ${Author}. All rights reserved." -f (Get-Date -Format 'yyyy')
$ProjectUri = 'https://github.com/tonysathre/CitrixAutodeploy'

$BasePath = "${PSScriptRoot}\module\CitrixAutodeploy"
$NestedModules = Get-ChildItem -Recurse ${BasePath}\functions\*.ps1 | ForEach-Object { ".\functions\$(Split-Path -Leaf $_.Directory)\$($_.Name)" }
$FunctionsToExport = (Get-ChildItem ${BasePath}\functions\public\*.ps1).Name -replace '\.ps1$'
$RequiredModules = @('PoShLog')
$ScriptsToProcess = @('.\functions\private\Initialize-InternalLogger.ps1')
$VariablesToExport = @('InternalLogger')


$ModuleManifest = @{
Author = $Author
CompanyName = $CompanyName
Description = $Description
Copyright = $Copyright
ProjectUri = $ProjectUri
ModuleVersion = $ModuleVersion
Path = "${BasePath}\CitrixAutodeploy.psd1"
FunctionsToExport = $FunctionsToExport
NestedModules = $NestedModules
RequiredModules = $RequiredModules
ScriptsToProcess = $ScriptsToProcess
VariablesToExport = $VariablesToExport
}

Update-PSModuleManifest @ModuleManifest
Loading