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, puede realizar las mismas tareas que haría con la consola MMC de StoreFront, junto con tareas que no puede realizar solo con la consola.

Nota:

El SDK de PowerShell no es compatible con PowerShell 6 o versiones posteriores.

Para la referencia del SDK, consulte 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úrese de que la consola de administración de StoreFront esté cerrada.

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

    Debe ejecutar el shell o el script utilizando un miembro del grupo de administradores locales en el servidor de StoreFront.

  3. Para usar los cmdlets del SDK en scripts, establezca 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, consulte la documentación de Microsoft.

Primeros pasos con el SDK

Para crear un script, siga estos pasos:

  1. Tome uno de los ejemplos de SDK proporcionados e instalados por StoreFront en la carpeta %ProgramFiles%\Citrix\Receiver StoreFront\PowerShellSDK\Examples.
  2. Para ayudarle a personalizar su propio script, revise el script de ejemplo para entender qué hace cada parte. Para obtener más información, consulte el caso de uso de ejemplo, que explica en detalle las acciones del script.
  3. Convierta y adapte los scripts de ejemplo para convertirlos en un script más fácil de usar. Para ello:
    • Utilice PowerShell ISE o una herramienta similar para editar el script.
    • Utilice variables para asignar valores que se van a reutilizar o modificar.
    • Elimine los comandos que no sean necesarios.
    • Tenga en cuenta que los cmdlets de StoreFront se pueden identificar por el prefijo STF.
    • Utilice 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 asegurarse de obtener siempre las últimas mejoras y correcciones, Citrix® recomienda seguir el procedimiento descrito anteriormente en lugar de copiar y pegar los scripts de ejemplo.

Ejemplos Descripción
Crear una implementación simple Script: crea una implementación simple 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 añadir 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 añadir 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 XenDesktop®.

Antes de empezar, asegúrese de seguir los pasos detallados en Introducción al SDK. Este ejemplo se puede personalizar utilizando los métodos descritos para producir un script que automatice la implementación de StoreFront.

Nota:

Para asegurarse de obtener siempre las últimas mejoras y correcciones, Citrix 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 le ayudará con la personalización de su propio script.

  • Establece los requisitos de gestión 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 aún no existe, en preparación para añadir los servicios de StoreFront necesarios. -Confirm:$false suprime el requisito de confirmar que la implementación puede proceder.

     \# 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 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 añadir una implementación con acceso remoto.

Antes de empezar, asegúrese de seguir los pasos detallados en Introducción al SDK. Este ejemplo se puede personalizar utilizando los métodos descritos para producir un script para automatizar la implementación de StoreFront.

Nota:

Para asegurarse de obtener siempre las últimas mejoras y correcciones, Citrix 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 le ayudará con la personalización de su propio script.

  • Establece los requisitos de gestión 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 ampliará 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 simple, 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 necesario para el acceso remoto mediante Citrix Gateway. Obtenga 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, añadiendo 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 Gateway de inicio óptimo

El siguiente ejemplo se basa en el script anterior para añadir una implementación con acceso remoto a Gateway de inicio óptimo.

Antes de empezar, asegúrese de seguir los pasos detallados en Introducción al SDK. Este ejemplo se puede personalizar utilizando los métodos descritos para producir un script para automatizar la implementación de StoreFront.

Nota:

Para asegurarse de obtener siempre las últimas mejoras y correcciones, Citrix 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 le ayudará con la personalización de su propio script.

  • Establece los requisitos de gestión 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 añadir 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-->
    
  • Añade 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 lanzamientos de 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