DSCResources/VE_XD7StoreFrontBaseUrl/VE_XD7StoreFrontBaseUrl.ps1
Import-LocalizedData -BindingVariable localizedData -FileName Resources.psd1; function Get-TargetResource { [CmdletBinding()] [OutputType([System.Collections.Hashtable])] param ( [Parameter(Mandatory)] [System.String] $BaseUrl ) begin { AssertXDModule -Name 'Citrix.DeliveryServices.Framework.Commands' -IsSnapin; } process { Add-PSSnapIn -Name 'Citrix.DeliveryServices.Framework.Commands' -ErrorAction Stop; $targetResource = @{ BaseUrl = Get-DSFrameworkProperty -Key 'HostBaseUrl'; } return $targetResource; } #end process } #end function Get-TargetResource function Test-TargetResource { [CmdletBinding()] [OutputType([System.Boolean])] param ( [Parameter(Mandatory)] [System.String] $BaseUrl ) process { $targetResource = Get-TargetResource @PSBoundParameters; if (-not $BaseUrl.EndsWith('/')) { $BaseUrl = '{0}/' -f $BaseUrl; } if ($BaseUrl -eq $targetResource.BaseUrl) { Write-Verbose ($localizedData.ResourceInDesiredState -f $BaseUrl); return $true; } else { Write-Verbose ($localizedData.ResourcePropertyMismatch -f 'BaseUrl', $BaseUrl, $targetResource.BaseUrl); Write-Verbose ($localizedData.ResourceNotInDesiredState -f $BaseUrl); return $false; } } } #end function Test-TargetResource function Set-TargetResource { [CmdletBinding()] param ( [Parameter(Mandatory)] [System.String] $BaseUrl ) begin { AssertXDModule -Name 'ClusterConfigurationModule','UtilsModule' -Path "$env:ProgramFiles\Citrix\Receiver StoreFront\Management"; } process { function global:Write-Host { [CmdletBinding()] param ( [Parameter(Position = 0, ValueFromPipeline, ValueFromRemainingArguments)] [System.Object] $Object, [System.Management.Automation.SwitchParameter] $NoNewLine, [System.ConsoleColor] $ForegroundColor, [System.ConsoleColor] $BackgroundColor ) foreach ($message in $Object) { Write-Verbose $message; } } $storefrontCmdletSearchPath = "$env:ProgramFiles\Citrix\Receiver StoreFront\Management"; Import-Module (FindXDModule -Name 'UtilsModule' -Path $storefrontCmdletSearchPath) -Scope Global -Verbose:$false; Import-Module (FindXDModule -Name 'ClusterConfigurationModule' -Path $storefrontCmdletSearchPath) -Scope Global -Verbose:$false; Write-Verbose ($localizedData.UpdatingBaseUrl -f $BaseUrl); [ref] $null = Set-DSClusterAddress -NewHostBaseUrl $BaseUrl; } #end process } #end function Set-TargetResource |