SDK de StoreFront
Citrix StoreFront proporciona un SDK basado en varios módulos de Microsoft Windows PowerShell versión 2.0. Con el SDK, puedes realizar las mismas tareas que harías con la consola MMC de StoreFront, junto con tareas que no puedes realizar solo con la consola.
Nota:
El SDK de PowerShell no es compatible con PowerShell 6 o superior.
Para la referencia del SDK, consulta SDK de StoreFront.
Uso del SDK
El SDK consta de varios complementos de PowerShell que el asistente de instalación instala automáticamente al instalar y configurar varios componentes de StoreFront.
Para acceder y ejecutar los cmdlets:
-
Asegúrate de que la consola de administración de StoreFront esté cerrada.
-
Inicia un símbolo del sistema de PowerShell o Windows PowerShell ISE como administrador.
Debes ejecutar el shell o el script con una cuenta que sea miembro del grupo de administradores locales en el servidor de StoreFront.
-
Para usar los cmdlets del SDK dentro de los scripts, establece la política de ejecución en PowerShell en RemoteSigned. Para obtener más información sobre la política de ejecución de PowerShell, consulta la documentación de Microsoft.
Primeros pasos con el SDK
Para crear un script, sigue estos pasos:
- Toma uno de los ejemplos de SDK proporcionados e instalados por StoreFront en la carpeta %ProgramFiles%\Citrix\Receiver StoreFront\PowerShellSDK\Examples.
- Para ayudarte a personalizar tu propio script, revisa el script de ejemplo para entender qué hace cada parte. Para obtener más información, consulta el caso de uso de ejemplo, que explica en detalle las acciones del script.
- Convierte y adapta los scripts de ejemplo para convertirlos en un script más utilizable. Para ello:
- Usa PowerShell ISE o una herramienta similar para editar el script.
- Usa variables para asignar valores que se reutilizarán o modificarán.
- Quita los comandos que no sean necesarios.
- Ten en cuenta que los cmdlets de StoreFront se pueden identificar por el prefijo STF.
- Usa el cmdlet Get-Help proporcionando el nombre del cmdlet y el parámetro -Full para obtener más información sobre un comando específico.
Ejemplos
Nota:
Al crear un script, para asegurarte de obtener siempre las últimas mejoras y correcciones, Citrix® te recomienda seguir el procedimiento descrito anteriormente en lugar de copiar y pegar los scripts de ejemplo.
| Ejemplos | Descripción |
|---|---|
| Crear una implementación sencilla | Script: crea una implementación sencilla con un controlador de StoreFront configurado con un único servidor XenDesktop. |
| Crear una implementación de acceso remoto | Script: se basa en el script anterior para agregar acceso remoto a la implementación. |
| Crear una implementación de acceso remoto con Gateway de inicio óptimo | Script: se basa en el script anterior para agregar gateways de inicio óptimo preferidos para una mejor experiencia de usuario. |
Ejemplo: Crear una implementación sencilla
El siguiente ejemplo muestra cómo crear una implementación sencilla configurada con un controlador XenDesktop®.
Antes de empezar, asegúrate de seguir los pasos detallados en Primeros pasos con el SDK. Este ejemplo se puede personalizar utilizando los métodos descritos para producir un script para automatizar la implementación de StoreFront.
Nota:
Para asegurarte de obtener siempre las últimas mejoras y correcciones, Citrix te recomienda seguir el procedimiento descrito en este documento, en lugar de copiar y pegar el script de ejemplo.
Entender el script
Esta sección explica qué hace cada parte del script producido por StoreFront. Esto te ayudará con la personalización de tu propio script.
-
Establece los requisitos de manejo de errores e importa los módulos de StoreFront necesarios. Las importaciones no son necesarias en versiones más recientes de PowerShell.
Param( [Parameter(Mandatory=$true)] [Uri]$HostbaseUrl, [long]$SiteId = 1, [ValidateSet("XenDesktop","XenApp","AppController","VDIinaBox")] [string]$Farmtype = "XenDesktop", [Parameter(Mandatory=$true)] [string[]]$FarmServers, [string]$StoreVirtualPath = "/Citrix/Store", [bool]$LoadbalanceServers = $false, [int]$Port = 80, [int]$SSLRelayPort = 443, [ValidateSet("HTTP","HTTPS","SSL")] [string]$TransportType = "HTTP" ) \# Import StoreFront modules. Required for versions of PowerShell earlier than 3.0 that do not support autoloading Import-Module Citrix.StoreFront Import-Module Citrix.StoreFront.Stores Import-Module Citrix.StoreFront.Authentication Import-Module Citrix.StoreFront.WebReceiver <!--NeedCopy--> -
Automatiza la ruta virtual de los servicios de autenticación y Citrix Receiver para Web basándose en la $StoreVirtualPath proporcionada. $StoreVirtualPath es equivalente a $StoreIISpath porque las rutas virtuales son siempre la ruta en IIS. Por lo tanto, en PowerShell tienen un valor como “/Citrix/Store”, “/Citrix/StoreWeb” o “/Citrix/StoreAuth”.
\# Determine the Authentication and Receiver virtual path to use based of the Store $authenticationVirtualPath = "$($StoreIISPath.TrimEnd('/'))Auth" $receiverVirtualPath = "$($StoreVirtualPath.TrimEnd('/'))Web" <!--NeedCopy--> -
Crea una nueva implementación si aún no existe, en preparación para agregar los servicios de StoreFront necesarios. -Confirm:$false suprime el requisito de confirmar que la implementación puede continuar.
\# Determine if the deployment already exists $existingDeployment = Get-STFDeployment if(-not $existingDeployment) { \# Install the required StoreFront components Add-STFDeployment -HostBaseUrl $HostbaseUrl -SiteId $SiteId -Confirm:$false } elseif($existingDeployment.HostbaseUrl -eq $HostbaseUrl) { \# The deployment exists but it is configured to the desired hostbase url Write-Output "A deployment has already been created with the specified hostbase url on this server and will be used." } else { Write-Error "A deployment has already been created on this server with a different host base url." } <!--NeedCopy--> -
Crea un nuevo servicio de autenticación si no existe uno en la ruta virtual especificada. Se habilita el método de autenticación predeterminado de nombre de usuario y contraseña.
\# Determine if the authentication service at the specified virtual path exists $authentication = Get-STFAuthenticationService -VirtualPath $authenticationVirtualPath if(-not $authentication) { \# Add an Authentication service using the IIS path of the Store appended with Auth $authentication = Add-STFAuthenticationService $authenticationVirtualPath } else { Write-Output "An Authentication service already exists at the specified virtual path and will be used." } <!--NeedCopy--> -
Crea el nuevo servicio de almacén configurado con un controlador XenDesktop con los servidores definidos en la matriz $XenDesktopServers en la ruta virtual especificada si aún no existe.
\# Determine if the store service at the specified virtual path exists $store = Get-STFStoreService -VirtualPath $StoreVirtualPath if(-not $store) { \# Add a Store that uses the new Authentication service configured to publish resources from the supplied servers $store = Add-STFStoreService -VirtualPath $StoreVirtualPath -AuthenticationService $authentication -FarmName $Farmtype -FarmType $Farmtype -Servers $FarmServers -LoadBalance $LoadbalanceServers \` -Port $Port -SSLRelayPort $SSLRelayPort -TransportType $TransportType } else { Write-Output "A Store service already exists at the specified virtual path and will be used. Farm and servers will be appended to this store." \# Get the number of farms configured in the store $farmCount = (Get-STFStoreFarmConfiguration $store).Farms.Count \# Append the farm to the store with a unique name Add-STFStoreFarm -StoreService $store -FarmName "Controller$($farmCount + 1)" -FarmType $Farmtype -Servers $FarmServers -LoadBalance $LoadbalanceServers -Port $Port \` -SSLRelayPort $SSLRelayPort -TransportType $TransportType } <!--NeedCopy--> -
Agrega un servicio Citrix Receiver™ para Web en la ruta virtual de IIS especificada para acceder a las aplicaciones publicadas en el almacén creado anteriormente.
\# Determine if the receiver service at the specified virtual path exists $receiver = Get-STFWebReceiverService -VirtualPath $receiverVirtualPath if(-not $receiver) { \# Add a Receiver for Web site so users can access the applications and desktops in the published in the Store $receiver = Add-STFWebReceiverService -VirtualPath $receiverVirtualPath -StoreService $store } else { Write-Output "A Web Receiver service already exists at the specified virtual path and will be used." } <!--NeedCopy--> -
Habilita los servicios de XenApp para el almacén para que los clientes más antiguos de Citrix Receiver o Citrix Workspace app puedan conectarse a las aplicaciones publicadas.
\# Determine if PNA is configured for the Store service $storePnaSettings = Get-STFStorePna -StoreService $store if(-not $storePnaSettings.PnaEnabled) { \# Enable XenApp services on the store and make it the default for this server Enable-STFStorePna -StoreService $store -AllowUserPasswordChange -DefaultPnaService } <!--NeedCopy-->
Ejemplo: Crear una implementación de acceso remoto
El siguiente ejemplo se basa en el script anterior para agregar una implementación con acceso remoto.
Antes de empezar, asegúrate de seguir los pasos detallados en Primeros pasos con el SDK. Este ejemplo se puede personalizar utilizando los métodos descritos para producir un script para automatizar la implementación de StoreFront.
Nota:
Para asegurarte de obtener siempre las últimas mejoras y correcciones, Citrix te recomienda seguir el procedimiento descrito en este documento, en lugar de copiar y pegar el script de ejemplo.
Entender el script
Esta sección explica qué hace cada parte del script producido por StoreFront. Esto te ayudará con la personalización de tu propio script.
-
Establece los requisitos de manejo de errores e importa los módulos de StoreFront necesarios. Las importaciones no son necesarias en versiones más recientes de PowerShell.
Param( [Parameter(Mandatory=$true)] [Uri]$HostbaseUrl, [Parameter(Mandatory=$true)] [long]$SiteId = 1, [string]$Farmtype = "XenDesktop", [Parameter(Mandatory=$true)] [string[]]$FarmServers, [string]$StoreVirtualPath = "/Citrix/Store", [bool]$LoadbalanceServers = $false, [int]$Port = 80, [int]$SSLRelayPort = 443, [ValidateSet("HTTP","HTTPS","SSL")] [string]$TransportType = "HTTP", [Parameter(Mandatory=$true)] [Uri]$GatewayUrl, [Parameter(Mandatory=$true)] [Uri]$GatewayCallbackUrl, [Parameter(Mandatory=$true)] [string[]]$GatewaySTAUrls, [string]$GatewaySubnetIP, [Parameter(Mandatory=$true)] [string]$GatewayName ) Set-StrictMode -Version 2.0 \# Any failure is a terminating failure. $ErrorActionPreference = 'Stop' $ReportErrorShowStackTrace = $true $ReportErrorShowInnerException = $true \# Import StoreFront modules. Required for versions of PowerShell earlier than 3.0 that do not support autoloading Import-Module Citrix.StoreFront Import-Module Citrix.StoreFront.Stores Import-Module Citrix.StoreFront.Roaming <!--NeedCopy--> -
Crea una implementación de StoreFront de acceso interno llamando al script de ejemplos anterior. La implementación base se extenderá para admitir el acceso remoto.
\# Create a simple deployment by invoking the SimpleDeployment example $scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent $scriptPath = Join-Path $scriptDirectory "SimpleDeployment.ps1" & $scriptPath -HostbaseUrl $HostbaseUrl -SiteId $SiteId -FarmServers $FarmServers -StoreVirtualPath $StoreVirtualPath -Farmtype $Farmtype \` -LoadbalanceServers $LoadbalanceServers -Port $Port -SSLRelayPort $SSLRelayPort -TransportType $TransportType <!--NeedCopy--> -
Obtiene los servicios creados en la implementación sencilla, ya que deben actualizarse para admitir el escenario de acceso remoto.
\# Determine the Authentication and Receiver sites based on the Store $store = Get-STFStoreService -VirtualPath $StoreVirtualPath $authentication = Get-STFAuthenticationService -StoreService $store $receiverForWeb = Get-STFWebReceiverService -StoreService $store <!--NeedCopy--> -
Habilita CitrixAGBasic en el servicio Citrix Receiver para Web requerido para el acceso remoto usando Citrix Gateway. Obtén el método de autenticación CitrixAGBasic y ExplicitForms de Citrix Receiver para Web de los protocolos compatibles.
\# Get the Citrix Receiver for Web CitrixAGBasic and ExplicitForms authentication method from the supported protocols \# Included for demonstration purposes as the protocol name can be used directly if known $receiverMethods = Get-STFWebReceiverAuthenticationMethodsAvailable | Where-Object { $_ -match "Explicit" -or $_ -match "CitrixAG" } \# Enable CitrixAGBasic in Receiver for Web (required for remote access) Set-STFWebReceiverService $receiverForWeb -AuthenticationMethods $receiverMethods <!--NeedCopy--> -
Habilita CitrixAGBasic en el servicio de autenticación. Esto es necesario para el acceso remoto.
\# Get the CitrixAGBasic authentication method from the protocols installed. \# Included for demonstration purposes as the protocol name can be used directly if known $citrixAGBasic = Get-STFAuthenticationProtocolsAvailable | Where-Object { $_ -match "CitrixAGBasic" } \# Enable CitrixAGBasic in the Authentication service (required for remote access) Enable-STFAuthenticationServiceProtocol -AuthenticationService $authentication -Name $citrixAGBasic <!--NeedCopy--> -
Agrega un nuevo Gateway de acceso remoto, si se proporciona la dirección IP de subred opcional, y lo registra con el almacén para que se acceda a él de forma remota.
\# Add a new Gateway used to access the new store remotely Add-STFRoamingGateway -Name "NetScaler10x" -LogonType Domain -Version Version10_0_69_4 -GatewayUrl $GatewayUrl ' \-CallbackUrl $GatewayCallbackUrl -SecureTicketAuthorityUrls $GatewaySTAUrls \# Get the new Gateway from the configuration (Add-STFRoamingGateway will return the new Gateway if -PassThru is supplied as a parameter) $gateway = Get-STFRoamingGateway -Name $GatewayName \# If the gateway subnet was provided then set it on the gateway object if($GatewaySubnetIP) { Set-STFRoamingGateway -Gateway $gateway -SubnetIPAddress $GatewaySubnetIP } \# Register the Gateway with the new Store Register-STFStoreGateway -Gateway $gateway -StoreService $store -DefaultGateway <!--NeedCopy-->
Ejemplo: Crear una implementación de acceso remoto con Gateway de inicio óptimo
El siguiente ejemplo se basa en el script anterior para agregar una implementación con acceso remoto de Gateway de inicio óptimo.
Antes de empezar, asegúrate de seguir los pasos detallados en Primeros pasos con el SDK. Este ejemplo se puede personalizar utilizando los métodos descritos para producir un script para automatizar la implementación de StoreFront.
Nota:
Para asegurarte de obtener siempre las últimas mejoras y correcciones, Citrix te recomienda seguir el procedimiento descrito en este documento, en lugar de copiar y pegar el script de ejemplo.
Entender el script
Esta sección explica qué hace cada parte del script producido por StoreFront. Esto te ayudará con la personalización de tu propio script.
-
Establece los requisitos de manejo de errores e importa los módulos de StoreFront necesarios. Las importaciones no son necesarias en versiones más recientes de PowerShell.
Param( [Parameter(Mandatory=$true)] [Uri]$HostbaseUrl, [long]$SiteId = 1, [string]$Farmtype = "XenDesktop", [Parameter(Mandatory=$true)] [string[]]$FarmServers, [string]$StoreVirtualPath = "/Citrix/Store", [bool]$LoadbalanceServers = $false, [int]$Port = 80, [int]$SSLRelayPort = 443, [ValidateSet("HTTP","HTTPS","SSL")] [string]$TransportType = "HTTP", [Parameter(Mandatory=$true)] [Uri]$GatewayUrl, [Parameter(Mandatory=$true)] [Uri]$GatewayCallbackUrl, [Parameter(Mandatory=$true)] [string[]]$GatewaySTAUrls, [string]$GatewaySubnetIP, [Parameter(Mandatory=$true)] [string]$GatewayName, [Parameter(Mandatory=$true)] [Uri]$OptimalGatewayUrl, [Parameter(Mandatory=$true)] [string[]]$OptimalGatewaySTAUrls, [Parameter(Mandatory=$true)] [string]$OptimalGatewayName ) Set-StrictMode -Version 2.0 \# Any failure is a terminating failure. $ErrorActionPreference = 'Stop' $ReportErrorShowStackTrace = $true $ReportErrorShowInnerException = $true \# Import StoreFront modules. Required for versions of PowerShell earlier than 3.0 that do not support autoloading Import-Module Citrix.StoreFront Import-Module Citrix.StoreFront.Stores Import-Module Citrix.StoreFront.Roaming <!--NeedCopy--> -
Llama al script de implementación de acceso remoto para configurar la implementación básica y agregar acceso remoto.
\# Create a remote access deployment $scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent $scriptPath = Join-Path $scriptDirectory "RemoteAccessDeployment.ps1" & $scriptPath -HostbaseUrl $HostbaseUrl -SiteId $SiteId -FarmServers $FarmServers -StoreVirtualPath $StoreVirtualPath -Farmtype $Farmtype \` -LoadbalanceServers $LoadbalanceServers -Port $Port -SSLRelayPort $SSLRelayPort -TransportType $TransportType \` -GatewayUrl $GatewayUrl -GatewayCallbackUrl $GatewayCallbackUrl -GatewaySTAUrls $GatewaySTAUrls -GatewayName $GatewayName <!--NeedCopy--> -
Agrega el gateway de inicio óptimo preferido y lo obtiene de la lista de gateways configurados.
\# Add a new Gateway used for remote HDX access to desktops and apps $gateway = Add-STFRoamingGateway -Name $OptimalGatewayName -LogonType UsedForHDXOnly -GatewayUrl $OptimalGatewayUrl -SecureTicketAuthorityUrls $OptimalGatewaySTAUrls -PassThru <!--NeedCopy--> -
Obtiene el servicio de almacén para usar el gateway óptimo, lo registra asignándolo a los inicios desde la granja de servidores nombrada.
\# Get the Store configured by SimpleDeployment.ps1 $store = Get-STFStoreService -VirtualPath $StoreVirtualPath \# Register the Gateway with the new Store for launch against all of the farms (currently just one) $farmNames = @($store.FarmsConfiguration.Farms | foreach { $_.FarmName }) Register-STFStoreOptimalLaunchGateway -Gateway $gateway -StoreService $store -FarmName $farmNames <!--NeedCopy-->