StoreFront™ 2507 LTSR

Módulos de PowerShell de StoreFront

Citrix StoreFront incluye varios módulos de Microsoft Windows PowerShell versión 2.0 que se instalan con StoreFront. Con estos módulos, puedes realizar las mismas tareas que harías con la consola de administración de StoreFront, además de otras tareas que no puedes hacer solo con la consola.

Nota:

Los módulos de PowerShell de StoreFront no son compatibles con PowerShell 6 o versiones posteriores.

Para consultar la referencia de los módulos de PowerShell, consulta la documentación para desarrolladores de StoreFront.

Empezar

  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 con una cuenta que sea miembro del grupo de administradores locales en el servidor de StoreFront.

  3. Para usar cmdlets dentro de scripts, establece la política de ejecución en PowerShell a RemoteSigned. Para obtener más información sobre la política de ejecución de PowerShell, consulta la documentación de Microsoft.

  4. Puedes usar los scripts de ejemplo como punto de partida.

  5. Usa el cmdlet Get-Help con el nombre del cmdlet y el parámetro -Full para obtener más información sobre un comando específico.

Ruta virtual

Los cmdlets para obtener o crear un almacén, un sitio web o servicios de autenticación utilizan un parámetro VirtualPath. Esta es la ruta donde la aplicación está alojada en IIS. La ruta del almacén y del sitio web también se puede encontrar en la consola de administración de StoreFront. Normalmente, por convención, la ruta de autenticación es la misma que la ruta del almacén con el sufijo Auth y la del sitio web es la misma que la ruta del almacén con el sufijo Web. Por ejemplo, para la ruta virtual del almacén /Citrix/Store, el servicio de autenticación tiene la ruta /Citrix/StoreAuth y el sitio web tiene la ruta /Citrix/StoreWeb.

Por ejemplo, para obtener un servicio de almacén cuya ruta es /Citrix/Store, ejecuta el comando:

Get-STFStoreService -VirtualPath '/Citrix/Store'
<!--NeedCopy-->

Si omites VirtualPath, se devolverán todos los servicios. Si solo hay un servicio, PowerShell lo trata como un único objeto.

ID de sitio

Algunos cmdlets incluyen un parámetro SiteId. Si tienes varias implementaciones en el mismo servidor en diferentes sitios de IIS, debes especificar el SiteId. Si solo tienes un sitio, el parámetro no es necesario.

Scripts de ejemplo

StoreFront incluye algunos scripts de ejemplo que puedes encontrar en la carpeta %ProgramFiles%\Citrix\Receiver StoreFront\PowerShellSDK\Examples. Puedes usarlos como plantillas para crear tus propios scripts.

  • Usa PowerShell ISE, Visual Studio Code o una herramienta similar para modificar el script.
  • Usa variables para asignar valores que se reutilizarán o modificarán.
  • Quita cualquier comando que no sea necesario.
  • Ten en cuenta que los cmdlets de StoreFront se pueden identificar por el prefijo STF.
Ejemplos Descripción
Crear una implementación sencilla Script: crea una implementación sencilla con un controlador de StoreFront configurado con un único sitio de CVAD.
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.

Crear una implementación sencilla

El siguiente ejemplo muestra cómo crear una implementación sencilla configurada con un sitio de CVAD.

Antes de empezar, asegúrate de seguir los pasos detallados en Empezar. Este ejemplo se puede personalizar para producir un script que automatice la implementación de StoreFront.

Esta sección explica lo que hace cada parte del script. 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 modernas 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 el $StoreVirtualPath proporcionado. $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 hay una presente, 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 sitio (también conocido como granja) 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 sitio 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 la aplicación Citrix Workspace 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. Este ejemplo se puede personalizar utilizando los métodos descritos para producir un script que automatice la implementación de StoreFront.

Esta sección explica lo que 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 modernas 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, necesario para el acceso remoto mediante 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. Este ejemplo se puede personalizar utilizando los métodos descritos para producir un script que automatice la implementación de StoreFront.

Entender el script

Esta sección explica lo que 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 modernas 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 el sitio nombrado.

     # 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-->
    
Módulos de PowerShell de StoreFront