Last active
July 29, 2019 13:08
-
-
Save iainbrighton/2479239caf5b917ccf3cf49e802b5646 to your computer and use it in GitHub Desktop.
Example XD7StoreFrontStore Composite Resource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
configuration XD7StoreFrontStore | |
{ | |
param ( | |
[Parameter(Mandatory = $true)] | |
[System.String] | |
$StoreName, | |
[Parameter(Mandatory = $true)] | |
[ValidateSet("Explicit", "Anonymous")] | |
[System.String] | |
$AuthType, | |
[Parameter(Mandatory = $true)] | |
[System.String[]] | |
$Servers, | |
[Parameter(Mandatory = $true)] | |
[System.String] | |
$FarmName, | |
[Parameter()] | |
[System.UInt32] | |
$Port, | |
[Parameter()] | |
[ValidateSet('HTTP', 'HTTPS', 'SSL')] | |
[System.String] | |
$TransportType, | |
[Parameter()] | |
[System.Boolean] | |
$LoadBalance, | |
[Parameter()] | |
[ValidateSet('XenApp', 'XenDesktop', 'AppController')] | |
[System.String] | |
$FarmType, | |
[Parameter()] | |
[System.String] | |
$AuthVirtualPath = "/Citrix/$($StoreName)auth", | |
[Parameter()] | |
[System.String] | |
$StoreVirtualPath = "/Citrix/$($StoreName)", | |
[Parameter()] | |
[System.UInt64] | |
$SiteId = 1, | |
[Parameter()] | |
[System.String[]] | |
$ServiceUrls, | |
[Parameter()] | |
[System.UInt32] | |
$SSLRelayPort, | |
[Parameter()] | |
[System.UInt32] | |
$AllFailedBypassDuration, | |
[Parameter()] | |
[System.UInt32] | |
$BypassDuration, | |
[Parameter()] | |
[System.String[]] | |
$Zones, | |
[Parameter()] | |
[System.Boolean] | |
$LockedDown, | |
[Parameter()] | |
[ValidateSet('Present', 'Absent')] | |
[System.String] | |
$Ensure = 'Present' | |
) | |
Import-DscResource -Name XD7StoreFrontAuthenticationService, XD7StoreFrontStoreBase, XD7StoreFrontStoreFarm -Module XenDesktop7 | |
XD7StoreFrontAuthenticationService $StoreName { | |
VirtualPath = $AuthVirtualPath | |
SiteId = $SiteId | |
Ensure = $Ensure | |
} | |
XD7StoreFrontStoreBase $StoreName { | |
StoreName = $StoreName | |
AuthType = $AuthType | |
AuthVirtualPath = $AuthVirtualPath | |
StoreVirtualPath = $StoreVirtualPath | |
LockedDown = $LockedDown | |
SiteId = $SiteId | |
Ensure = $Ensure | |
DependsOn = "[XD7StoreFrontAuthenticationService]$StoreName" | |
} | |
function Get-DscSplattedResource { | |
<# | |
.LINK | |
https://gaelcolas.com/2017/11/05/pseudo-splatting-dsc-resources/ | |
#> | |
[CmdletBinding()] | |
Param( | |
[String] | |
$ResourceName, | |
[String] | |
$ExecutionName, | |
[hashtable] | |
$Properties | |
) | |
$stringBuilder = [System.Text.StringBuilder]::new() | |
$null = $stringBuilder.AppendLine("Param([hashtable]`$Parameters)") | |
$null = $stringBuilder.AppendLine(" $ResourceName $ExecutionName { ") | |
foreach($PropertyName in $Properties.keys) { | |
$null = $stringBuilder.AppendLine("$PropertyName = `$(`$Parameters['$PropertyName'])") | |
} | |
$null = $stringBuilder.AppendLine("}") | |
Write-Debug ("Generated Resource Block = {0}" -f $stringBuilder.ToString()) | |
[scriptblock]::Create($stringBuilder.ToString()).Invoke($Properties) | |
} | |
$permittedXD7StoreFrontStoreFarmParams = @( | |
'StoreName', | |
'FarmName', | |
'FarmType', | |
'Servers', | |
'ServiceUrls', | |
'Port', | |
'TransportType', | |
'SSLRelayPort', | |
'LoadBalance', | |
'AllFailedBypassDuration', | |
'BypassDuration', | |
'Zones' | |
) | |
foreach ($parameterName in $($PSBoundParameters.Keys)) | |
{ | |
if ($permittedXD7StoreFrontStoreFarmParams -notcontains $parameterName) | |
{ | |
$PSBoundParameters.Remove($parameterName) | |
} | |
} | |
$PSBoundParameters['DependsOn'] = "[XD7StoreFrontStoreBase]$StoreName" | |
$PSBoundParameters['Ensure'] = $Ensure | |
Get-DscSplattedResource XD7StoreFrontStoreFarm $StoreName $PSBoundParameters | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment