StoreFront

ストアフロント エスディーケー

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 documentationを参照してください。

SDKの使用を開始する

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

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

使用例

注:

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

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

例: シンプルな展開を作成する

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

開始する前に、Get Started with the 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-->
    
  • Enables CitrixAGBasic on the Citrix Receiver for Web service required for remote access using Citrix Gateway. Get the Citrix Receiver for Web CitrixAGBasic and ExplicitForms authentication method from the supported protocols.

     \# 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リモートアクセスを含む展開を追加します。

開始する前に、Get Started with the 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-->
    
  • 優先する最適な起動Gatewayを追加し、構成済みのGatewayのリストからそれを取得します。

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

     \# 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-->
    
ストアフロント エスディーケー