StoreFront PowerShell モジュール
Citrix StoreFront には、StoreFront のインストール時に含まれる Microsoft Windows PowerShell バージョン 2.0 モジュールが多数用意されています。これらのモジュールを使用すると、StoreFront 管理コンソールで行うのと同じタスクを実行できるほか、コンソールだけでは実行できないタスクも実行できます。
注:
StoreFront PowerShell モジュールは、PowerShell 6 以降との互換性はありません。
PowerShell モジュールのリファレンスについては、StoreFront 開発者向けドキュメントを参照してください。
はじめに
-
StoreFront 管理コンソールが閉じていることを確認します。
-
PowerShell コマンドラインプロンプトまたは Windows PowerShell ISE を管理者として起動します。
StoreFront サーバーのローカル管理者グループのメンバーを使用して、シェルまたはスクリプトを実行する必要があります。
-
スクリプト内でコマンドレットを使用するには、PowerShell の実行ポリシーを RemoteSigned に設定します。PowerShell の実行ポリシーの詳細については、Microsoft ドキュメントを参照してください。
-
スクリプトの例を開始点として使用できます。
-
特定のコマンドの詳細については、コマンドレット名と -Full パラメーターを指定して Get-Help コマンドレットを使用します。
仮想パス
ストア、Webサイト、または認証サービスを取得または作成するコマンドレットは、VirtualPathパラメーターを受け取ります。これは、IIS内でアプリケーションがホストされているパスです。ストアとWebサイトのパスは、StoreFront管理コンソールでも確認できます。通常、慣例により、認証パスはストアパスにサフィックスAuthを付けたものと同じであり、WebサイトはストアパスにサフィックスWebを付けたものと同じです。例として、ストアの仮想パスが/Citrix/Storeの場合、認証サービスはパス/Citrix/StoreAuthを持ち、Webサイトはパス/Citrix/StoreWebを持ちます。
例として、パスが/Citrix/Storeであるストアサービスを取得するには、次のコマンドを実行します。
Get-STFStoreService -VirtualPath '/Citrix/Store'
<!--NeedCopy-->
VirtualPath を省略すると、すべてのサービスが返されます。サービスが1つしかない場合、PowerShell はこれを単一のオブジェクトとして扱います。
サイトID
一部のコマンドレットには SiteId パラメーターが含まれています。同じサーバー上の異なる IIS サイトに複数の展開がある場合は、SiteId を指定する必要があります。サイトが1つしかない場合は、このパラメーターは不要です。
スクリプトの例
StoreFront には、%ProgramFiles%\Citrix\Receiver StoreFront\PowerShellSDK\Examples フォルダーにあるいくつかのスクリプトの例が含まれています。これらを独自のスクリプトを作成するためのテンプレートとして使用できます。
- PowerShell ISE、Visual Studio Code、または同様のツールを使用してスクリプトを編集します。
- 変数を再利用または変更する値に割り当てます。
- 不要なコマンドは削除します。
- StoreFront コマンドレットは、プレフィックス STF で識別できることに注意してください。
| 例 | 説明 |
|---|---|
| シンプルな展開の作成 | スクリプト: 単一の CVAD サイトで構成された StoreFront コントローラーを使用して、シンプルな展開を作成します。 |
| リモートアクセス展開の作成 | スクリプト: 以前のスクリプトに基づいて、展開にリモートアクセスを追加します。 |
| 最適な起動ゲートウェイによるリモートアクセス展開の作成 | スクリプト: 以前のスクリプトに基づいて、より良いユーザーエクスペリエンスのために優先される最適な起動ゲートウェイを追加します。 |
シンプルな展開の作成
次の例は、1つの CVAD サイトで構成されたシンプルな展開を作成する方法を示しています。
開始する前に、はじめにで詳述されている手順に従ってください。この例は、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つのサイト(ファームとも呼ばれます)で構成された新しいストアサービスを作成します。
# 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 仮想パスに 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-->
例: リモートアクセス展開の作成
次の例は、以前のスクリプトに基づいて、リモートアクセスを含む展開を追加します。
開始する前に、はじめにで詳述されている手順に従ってください。この例は、StoreFront 展開を自動化するためのスクリプトを作成するために、説明されている方法を使用してカスタマイズできます。
このセクションでは、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-->
例: 最適な起動ゲートウェイによるリモートアクセス展開の作成
次の例は、以前のスクリプトに基づいて、最適な起動ゲートウェイによるリモートアクセスを含む展開を追加します。
開始する前に、はじめにで詳述されている手順に従ってください。この例は、StoreFront 展開を自動化するためのスクリプトを作成するために、説明されている方法を使用してカスタマイズできます。
スクリプトの理解
このセクションでは、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-->