StoreFront

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 hacer solo con la consola.

Nota:

El SDK de PowerShell no es compatible con PowerShell 6 o superior.

Para consultar la referencia del SDK, consulta StoreFront SDK.

Usar el SDK

El SDK se compone 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:

  1. Asegúrate de que la consola de administración de StoreFront esté cerrada.

  2. Inicia un símbolo del sistema de PowerShell o Windows PowerShell ISE como administrador.

    Debes ejecutar el shell o el script usando una cuenta que sea miembro del grupo de administradores locales en el servidor de StoreFront.

  3. 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.

Empezar a usar el SDK

Para crear un script, sigue estos pasos:

  1. Toma uno de los ejemplos del SDK proporcionados e instalados por StoreFront en la carpeta %ProgramFiles%\Citrix\Receiver StoreFront\PowerShellSDK\Examples.
  2. Para ayudarte a personalizar tu propio script, revisa el script de ejemplo para comprender 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.
  3. Convierte y adapta los scripts de ejemplo para convertirlos en un script más fácil de usar. Para ello:
    • Usa PowerShell ISE o una herramienta similar para modificar el script.
    • Usa variables para asignar valores que se van a reutilizar o modificar.
    • 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 solo servidor de 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 puerta de enlace de inicio óptimo Script: se basa en el script anterior para agregar puertas de enlace de inicio óptimo preferidas 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 de XenDesktop®.

Antes de empezar, asegúrate de seguir los pasos detallados en Empezar a usar el SDK. Este ejemplo se puede personalizar usando 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.

Comprender el script

Esta sección explica qué hace cada parte del script producido por StoreFront. Esto te ayudará a personalizar tu propio script.

  • Establece los requisitos de manejo de errores e importa los módulos de StoreFront necesarios. Las importaciones no son necesarias en las 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 no hay ninguna presente, en preparación para agregar los servicios de StoreFront requeridos. -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 de XenDesktop con los servidores definidos en la matriz $XenDesktopServers en la ruta virtual especificada si no existe uno.

     \# 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 de 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 de Citrix Receiver o Citrix Workspace app más antiguos 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 Empezar a usar el SDK. Este ejemplo se puede personalizar usando 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.

Comprender el script

Esta sección explica qué hace cada parte del script producido por StoreFront. Esto te ayudará a personalizar tu propio script.

  • Establece los requisitos de manejo de errores e importa los módulos de StoreFront necesarios. Las importaciones no son necesarias en las 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 de 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 admitidos.

     \# 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 una nueva puerta de enlace de acceso remoto, agregando la dirección IP de subred opcional si se proporciona y la registra con el almacén para que se acceda a ella 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 puerta de enlace de inicio óptimo

El siguiente ejemplo se basa en el script anterior para agregar una implementación con acceso remoto de puerta de enlace de inicio óptimo.

Antes de empezar, asegúrate de seguir los pasos detallados en Empezar a usar el SDK. Este ejemplo se puede personalizar usando 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.

Comprender el script

Esta sección explica qué hace cada parte del script producido por StoreFront. Esto te ayudará a personalizar tu propio script.

  • Establece los requisitos de manejo de errores e importa los módulos de StoreFront necesarios. Las importaciones no son necesarias en las 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 la puerta de enlace de inicio óptimo preferida y la obtiene de la lista de puertas de enlace configuradas.

     \# 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 la puerta de enlace óptima, lo registra asignándolo a los inicios desde la granja con nombre.

     \# 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-->
    
SDK de StoreFront