StoreFront

StoreFront SDK

Citrix StoreFrontは、Microsoft Windows PowerShellバージョン2.0モジュールをベースにしたSDKを提供します。このSDKを使用すると、StoreFront MMCコンソールで行うのと同じタスクに加え、コンソール単独では実行できないタスクも実行できます。

注:

PowerShell SDKは、PowerShell 6以降との互換性はありません。

SDKリファレンスについては、StoreFront SDKを参照してください。

SDKの使用

SDKは、さまざまなStoreFrontコンポーネントをインストールおよび構成する際に、インストールウィザードによって自動的にインストールされる複数のPowerShellスナップインで構成されています。

コマンドレットにアクセスして実行するには:

  1. StoreFront管理コンソールが閉じていることを確認します。

  2. PowerShellコマンドラインプロンプトまたはWindows PowerShell ISEを管理者として起動します。

    StoreFrontサーバーのローカル管理者グループのメンバーを使用して、シェルまたはスクリプトを実行する必要があります。

  3. スクリプト内でSDKコマンドレットを使用するには、PowerShellの実行ポリシーをRemoteSignedに設定します。PowerShellの実行ポリシーの詳細については、Microsoftドキュメントを参照してください。

SDKの開始

スクリプトを作成するには、次の手順を実行します。

  1. StoreFrontによって%ProgramFiles%\Citrix\Receiver StoreFront\PowerShellSDK\Examplesフォルダーにインストールされている提供済みのSDK例のいずれかを使用します。
  2. 独自のスクリプトをカスタマイズするために、例のスクリプトを確認して、各部分が何をしているかを理解します。詳細については、スクリプトの動作を詳細に説明している使用例を参照してください。
  3. 例のスクリプトを変換および適応させて、より使いやすいスクリプトにします。これを行うには:
    • PowerShell ISEまたは同様のツールを使用してスクリプトを編集します。
    • 再利用または変更する値を割り当てるために変数を使用します。
    • 不要なコマンドを削除します。
    • StoreFrontコマンドレットは、プレフィックスSTFで識別できることに注意してください。
    • 特定のコマンドの詳細については、コマンドレット名と-Fullパラメーターを指定してGet-Helpコマンドレットを使用します。

注:

スクリプトを作成する際は、常に最新の機能強化と修正が適用されるように、例のスクリプトをコピー&ペーストするのではなく、上記の手順に従うことをCitrix®は推奨します。

説明
シンプルな展開の作成 スクリプト:単一のXenDesktopサーバーで構成されたStoreFrontコントローラーによるシンプルな展開を作成します。
リモートアクセス展開の作成 スクリプト:以前のスクリプトに基づいて、展開にリモートアクセスを追加します。
最適な起動ゲートウェイによるリモートアクセス展開の作成 スクリプト:以前のスクリプトに基づいて、より良いユーザーエクスペリエンスのために優先される最適な起動ゲートウェイを追加します。

例:シンプルな展開の作成

次の例は、1つのXenDesktop®コントローラーで構成されたシンプルな展開を作成する方法を示しています。

開始する前に、SDKの開始で詳述されている手順に従っていることを確認してください。この例は、StoreFront展開を自動化するためのスクリプトを作成するために、説明されている方法を使用してカスタマイズできます。

注:

常に最新の機能強化と修正が適用されるように、例のスクリプトをコピー&ペーストするのではなく、このドキュメントに記載されている手順に従うことをCitrixは推奨します。

スクリプトの理解

このセクションでは、StoreFrontによって生成されたスクリプトの各部分が何をしているかを説明します。これは、独自のスクリプトをカスタマイズするのに役立ちます。

  • エラー処理要件を設定し、必要なStoreFrontモジュールをインポートします。新しいバージョンの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-->
    
  • 提供された$StoreVirtualPathに基づいて、認証サービスとCitrix Receiver for Webサービスの仮想パスを自動化します。仮想パスは常にIIS内のパスであるため、$StoreVirtualPath$StoreIISpathと同等です。したがって、PowerShellでは「/Citrix/Store」、「/Citrix/StoreWeb」、または「/Citrix/StoreAuth」のような値になります。

     \# Determine the Authentication and Receiver virtual path to use based of the Store
     $authenticationVirtualPath = "$($StoreIISPath.TrimEnd('/'))Auth"
     $receiverVirtualPath = "$($StoreVirtualPath.TrimEnd('/'))Web"
     <!--NeedCopy-->
    
  • 必要なStoreFrontサービスを追加する準備として、展開がまだ存在しない場合は新しい展開を作成します。-Confirm:$falseは、展開を進めることの確認要件を抑制します。

     \# 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-->
    
  • 指定された仮想パスに認証サービスが存在しない場合、新しい認証サービスを作成します。ユーザー名とパスワードのデフォルトの認証方法が有効になります。

     \# 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-->
    
  • 指定された仮想パスにストアサービスがまだ存在しない場合、配列$XenDesktopServersで定義されたサーバーを持つ1つのXenDesktopコントローラーで構成された新しいストアサービスを作成します。

     \# 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-->
    
  • 上記で作成されたストアで公開されているアプリケーションにアクセスするために、指定されたIIS仮想パスにCitrix Receiver™ for Webサービスを追加します。

     \# 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-->
    
  • ストアのXenAppサービスを有効にし、古いCitrix ReceiverまたはCitrix Workspaceアプリクライアントが公開されたアプリケーションに接続できるようにします。

     \# 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-->
    

例:リモートアクセス展開の作成

次の例は、以前のスクリプトに基づいて、リモートアクセスを含む展開を追加します。

開始する前に、SDKの開始で詳述されている手順に従っていることを確認してください。この例は、StoreFront展開を自動化するためのスクリプトを作成するために、説明されている方法を使用してカスタマイズできます。

注:

常に最新の機能強化と修正が適用されるように、例のスクリプトをコピー&ペーストするのではなく、このドキュメントに記載されている手順に従うことをCitrixは推奨します。

スクリプトの理解

このセクションでは、StoreFrontによって生成されたスクリプトの各部分が何をしているかを説明します。これは、独自のスクリプトをカスタマイズするのに役立ちます。

  • エラー処理要件を設定し、必要なStoreFrontモジュールをインポートします。新しいバージョンの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-->
    
  • 以前の例のスクリプトを呼び出すことにより、内部アクセスStoreFront展開を作成します。ベース展開は、リモートアクセスをサポートするように拡張されます。

     \# 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-->
    
  • リモートアクセスシナリオをサポートするために更新する必要があるため、シンプルな展開で作成されたサービスを取得します。

     \# 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-->
    
  • Citrix Gatewayを使用したリモートアクセスに必要なCitrix Receiver for WebサービスでCitrixAGBasicを有効にします。サポートされているプロトコルからCitrix Receiver for Web CitrixAGBasicおよびExplicitForms認証方法を取得します。

     \# 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-->
    
  • 認証サービスでCitrixAGBasicを有効にします。これはリモートアクセスに必要です。

     \# 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-->
    
  • 新しいリモートアクセスゲートウェイを追加し、オプションのサブネットIPアドレスが提供されている場合はそれを追加し、リモートでアクセスされるストアに登録します。

     \# 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-->
    

例:最適な起動ゲートウェイによるリモートアクセス展開の作成

次の例は、以前のスクリプトに基づいて、最適な起動ゲートウェイによるリモートアクセスを含む展開を追加します。

開始する前に、SDKの開始で詳述されている手順に従っていることを確認してください。この例は、StoreFront展開を自動化するためのスクリプトを作成するために、説明されている方法を使用してカスタマイズできます。

注:

常に最新の機能強化と修正が適用されるように、例のスクリプトをコピー&ペーストするのではなく、このドキュメントに記載されている手順に従うことをCitrixは推奨します。

スクリプトの理解

このセクションでは、StoreFrontによって生成されたスクリプトの各部分が何をしているかを説明します。これは、独自のスクリプトをカスタマイズするのに役立ちます。

  • エラー処理要件を設定し、必要なStoreFrontモジュールをインポートします。新しいバージョンの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-->
    
  • リモートアクセス展開スクリプトを呼び出して、基本的な展開を構成し、リモートアクセスを追加します。

     \# 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-->
    
  • 優先される最適な起動ゲートウェイを追加し、構成されたゲートウェイのリストからそれを取得します。

     \# 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-->
    
  • 最適なゲートウェイを使用するストアサービスを取得し、指定されたファームからの起動に割り当てて登録します。

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

この記事の概要