StoreFront

SDK de StoreFront

Citrix StoreFront proporciona un SDK basado en una serie de módulos de Microsoft Windows PowerShell 3.0. Con el SDK, se pueden realizar las mismas tareas que se llevan a cabo con la consola MMC de StoreFront, junto con otras tareas que no se pueden realizar con la consola.

Para la referencia del SDK, consulte SDK de StoreFront.

Uso de SDK

El SDK se compone de una serie de complementos de PowerShell que el asistente de instalación instala automáticamente cuando se instalan y se configuran varios componentes de StoreFront.

Para acceder a los cmdlets y ejecutarlos:

  1. Inicie una línea de comandos de PowerShell o ISE de Windows PowerShell como administrador.

    Debe ejecutar el shell o el script con una cuenta miembro del grupo de administradores locales en el servidor de StoreFront.

  2. Para utilizar los cmdlets del SDK en scripts, configure la directiva de ejecución en PowerShell.

    Para obtener más información acerca de la directiva de ejecución de PowerShell, consulte la documentación de Microsoft.

  3. Agregue los módulos que necesite al entorno de PowerShell con el comando Add -Module en la consola de Windows PowerShell. Por ejemplo, escriba:

    Import-Module Citrix.StoreFront

    Para importar todos los cmdlets, escriba:

    Get-Module -ListAvailable | Where-Object { $_.Name.StartsWith("Citrix.StoreFront") } | Import-Module

Después de realizar la importación, tendrá acceso a los cmdlets y a la ayuda asociada.

Introducción al SDK

Para crear un script, siga los siguientes pasos:

  1. Tome uno de los ejemplos del SDK instalado por StoreFront en la carpeta %ProgramFiles%\Citrix\Receiver StoreFront\PowerShellSDK\Examples.
  2. Para ayudarle a personalizar su propio script, consulte el script de ejemplo para comprender lo que hace cada parte. Para obtener más información, consulte el caso de uso de ejemplo que describe con más detalle las acciones del script.
  3. Adapte los scripts de ejemplo para convertirlos en scripts más útiles para su consumo. Para hacerlo:
    • Use PowerShell ISE o una herramienta similar para modificar el script.
    • Utilice variables para asignarles valores que se van a volver a utilizar o modificar.
    • Elimine los comandos que no sean necesarios.
    • Observe que los cmdlets de StoreFront se pueden identificar por el prefijo STF.
    • Use el cmdlet Get-Help con el nombre de un cmdlet y el parámetro -Full para obtener más información acerca de un comando en concreto.

Ejemplos

Nota:

Al crear un script, para asegurarse de obtener siempre las mejoras y revisiones más recientes, Citrix recomienda seguir el procedimiento descrito en este tema en lugar de copiar y pegar el script de ejemplo.

Ejemplos Descripción
Crear una implementación simple Script: crea una implementación simple de StoreFront con un controlador configurado con un único servidor XenDesktop.
Crear una implementación para acceso remoto Script: Se basa en el script anterior y agrega acceso remoto a la implementación.
Crear una implementación para acceso remoto con una puerta de enlace óptima Script: Se basa en el script anterior y agrega puertas de enlace preferidas óptimas para mejorar la experiencia del usuario.

Ejemplo: Crear una implementación simple

El siguiente ejemplo muestra cómo crear una implementación simple configurada con un Controller de XenDesktop.

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

Nota:

Para asegurarse de que siempre obtiene las últimas mejoras y revisiones, Citrix 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 generado por StoreFront. Esto le ayudará con la personalización de su propio script.

  • Establece los requisitos para la gestión de errores e importa los módulos de StoreFront necesarios. La importación no es necesaria en versiones más nuevas 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 ruta $StoreVirtualPath proporcionada. $StoreVirtualPath equivale a $StoreIISpath porque las rutas virtuales siempre son la ruta de 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 todavía no hay ninguna, como preparación para agregar los servicios de StoreFront. -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 todavía no hay ninguno en la ruta virtual especificada El método de autenticación predeterminado de nombre de usuario y contraseña está habilitado.

     # 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 un nuevo servicio de almacén configurado con un Controller de XenDesktop con los servidores en la matriz $XenDesktopServers en la ruta virtual especificada, si todavía no existe ninguna.

     # 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 obtener acceso 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 XenApp Services para el almacén de modo que las versiones anteriores de clientes de Citrix Receiver o de la aplicación 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 para acceso remoto

El siguiente ejemplo se basa en el script anterior y agrega una implementación de acceso remoto.

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

Nota:

Para asegurarse de que siempre obtiene las últimas mejoras y revisiones, Citrix 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 generado por StoreFront. Esto le ayudará con la personalización de su propio script.

  • Establece los requisitos para la gestión de errores e importa los módulos de StoreFront necesarios. La importación no es necesaria en versiones más nuevas 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-->
    
  • Cree una implementación de StoreFront de acceso interno ejecutando los scripts de los ejemplos anteriores. La implementación básica se ampliará para ofrecer 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 porque tienen que actualizarse para admitir el caso 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 a través de Citrix Gateway. Obtiene el método de autenticación ExplicitForms y CitrixAGBasic 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, lo que agrega la dirección IP de subred optativa y la registra con el almacén al que se va a acceder 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 para acceso remoto con una puerta de enlace óptima

El siguiente ejemplo se basa en el script anterior y agrega una implementación de acceso remoto con puerta de enlace de inicio óptima.

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

Nota:

Para asegurarse de que siempre obtiene las últimas mejoras y revisiones, Citrix 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 generado por StoreFront. Esto le ayudará con la personalización de su propio script.

  • Establece los requisitos para la gestión de errores e importa los módulos de StoreFront necesarios. La importación no es necesaria en versiones más nuevas 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 agregarle el 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 preferencia de puerta de enlace de inicio óptima y la obtiene de las 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 del almacén para usar la puerta de enlace óptima, registrarla y asignarla a inicios desde una comunidad especificada.

     # 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