StoreFront

ストアフロント SDK

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

注:

パワーシェル ソフトウェア開発キットは、パワーシェル 6 以降と互換性がありません。

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

SDK の使用

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

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

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

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

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

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

SDK の使用を開始する

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

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

使用例

注:

スクリプトを作成する際は、最新の機能強化と修正を常に確実に取得するために、サンプルスクリプトをコピー&ペーストするのではなく、上記の手順に従うことを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-->
    
  • 新しいリモートアクセスGatewayを追加し、オプションのサブネット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-->
    

例: 最適な起動Gatewayを使用したリモートアクセス展開の作成

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

開始する前に、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-->
    
ストアフロント SDK