複数の Windows Admin Center サーバーを持つ大規模な組織がある場合は、PowerShell を使用して、一度に複数のサーバーの接続と拡張機能の一覧を構成できます。
PowerShell を使用して接続をインポートまたはエクスポートする (タグ付き)
# Load the module
Import-Module "$env:ProgramFiles\windows admin center\PowerShell\Modules\ConnectionTools"
# Available cmdlets: Export-Connection, Import-Connection
# Export connections (including tags) to a .csv file
Export-Connection "https://wac.contoso.com" -fileName "WAC-connections.csv"
# Import connections (including tags) from a .csv file
Import-Connection "https://wac.contoso.com" -fileName "WAC-connections.csv"
# Import connections (including tags) from .csv files, and remove any connections that are not explicitly in the imported file by using the -prune switch parameter
Import-Connection "https://wac.contoso.com" -fileName "WAC-connections.csv" -prune
接続をインポートするための CSV ファイル形式
CSV ファイルの形式は、次の 4 つの見出しから始まり、その後に各接続が新しい行に続きます。
name
: 接続の FQDN。type
: 接続の種類。 Windows Admin Center に含まれる既定の接続では、次のいずれかの文字列を使用します。接続の種類 接続文字列 Windows Server msft.sme.connection-type.server
フェールオーバー クラスター msft.sme.connection-type.cluster
tags
: パイプで区切られたタグ。groupId
: 共有接続の列。 この列のglobal
値を使用して、共有接続を作成します。
手記
共有接続の変更は、ゲートウェイ管理者に限定されます。 任意のユーザーが PowerShell を使用して個人用接続リストを変更できます。
接続をインポートするための CSV ファイルの例
"name","type","tags","groupId"
"myServer.contoso.com","msft.sme.connection-type.server","hyperv"
"myDesktop.contoso.com","msft.sme.connection-type.windows-server","hyperv"
"teamcluster.contoso.com","msft.sme.connection-type.cluster","legacyCluster|WS2016","global"
"myHCIcluster.contoso.com,"msft.sme.connection-type.cluster","myHCIcluster|hyperv|JIT|WS2019"
"teamclusterNode.contoso.com","msft.sme.connection-type.server","legacyCluster|WS2016","global"
"myHCIclusterNode.contoso.com","msft.sme.connection-type.server","myHCIcluster|hyperv|JIT|WS2019"
手記
CSV ファイルでは大文字と小文字が区別されます。
RDCMan 接続のインポート
次のスクリプトを使用して、RDCMan の保存された接続をファイルにエクスポートします。 その後、ファイルを Windows Admin Center にインポートし、タグを使用して RDCMan グループ化階層を維持できます。
次のコードをコピーして PowerShell セッションに貼り付けます。
#Helper function for RdgToWacCsv function AddServers { param ( [Parameter(Mandatory = $true)] [Xml.XmlLinkedNode] $node, [Parameter()] [String[]] $tags, [Parameter(Mandatory = $true)] [String] $csvPath ) if ($node.LocalName -eq 'server') { $serverName = $node.properties.name $tagString = $tags -join "|" Add-Content -Path $csvPath -Value ('"'+ $serverName + '","msft.sme.connection-type.server","'+ $tagString +'"') } elseif ($node.LocalName -eq 'group' -or $node.LocalName -eq 'file') { $groupName = $node.properties.name $tags+=$groupName $currNode = $node.properties.NextSibling while ($currNode) { AddServers -node $currNode -tags $tags -csvPath $csvPath $currNode = $currNode.NextSibling } } else { # Node type isn't relevant to tagging or adding connections in Windows Admin Center } return } <# .SYNOPSIS Convert an .rdg file from Remote Desktop Connection Manager into a .csv that can be imported into Windows Admin Center, maintaining groups via server tags. This will not modify the existing .rdg file and will create a new .csv file .DESCRIPTION This converts an .rdg file into a .csv that can be imported into Windows Admin Center. .PARAMETER RDGfilepath The path of the .rdg file to be converted. This file will not be modified, only read. .PARAMETER CSVdirectory Optional. The directory you want to export the new .csv file. If it's not provided, the new file is created in the same directory as the .rdg file. .EXAMPLE C:\PS> RdgToWacCsv -RDGfilepath "rdcmangroup.rdg" #> function RdgToWacCsv { param( [Parameter(Mandatory = $true)] [String] $RDGfilepath, [Parameter(Mandatory = $false)] [String] $CSVdirectory ) [xml]$RDGfile = Get-Content -Path $RDGfilepath $node = $RDGfile.RDCMan.file if (!$CSVdirectory){ $csvPath = [System.IO.Path]::GetDirectoryName($RDGfilepath) + [System.IO.Path]::GetFileNameWithoutExtension($RDGfilepath) + "_WAC.csv" } else { $csvPath = $CSVdirectory + [System.IO.Path]::GetFileNameWithoutExtension($RDGfilepath) + "_WAC.csv" } New-item -Path $csvPath Add-Content -Path $csvPath -Value '"name","type","tags"' AddServers -node $node -csvPath $csvPath Write-Host "Converted $RDGfilepath `nOutput: $csvPath" }
CSV ファイルを作成するには、次のコマンドを実行します。
RdgToWacCsv -RDGfilepath "path\to\myRDCManfile.rdg"
結果の CSV ファイルを Windows Admin Center にインポートします。 接続リストのタグは、RDCMan グループ化階層を表します。
PowerShell を使用して Windows Admin Center 拡張機能を管理する
# Add the module to the current session
Import-Module "$env:ProgramFiles\windows admin center\PowerShell\Modules\ExtensionTools"
# Available cmdlets: Get-Feed, Add-Feed, Remove-Feed, Get-Extension, Install-Extension, Uninstall-Extension, Update-Extension
# List feeds
Get-Feed "https://wac.contoso.com"
# Add a new extension feed
Add-Feed -GatewayEndpoint "https://wac.contoso.com" -Feed "\\WAC\our-private-extensions"
# Remove an extension feed
Remove-Feed -GatewayEndpoint "https://wac.contoso.com" -Feed "\\WAC\our-private-extensions"
# List all extensions
Get-Extension "https://wac.contoso.com"
# Install an extension (locate the latest version from all feeds and install it)
Install-Extension -GatewayEndpoint "https://wac.contoso.com" "msft.sme.containers"
# Install an extension (latest version from a specific feed, if the feed is not present, it will be added)
Install-Extension -GatewayEndpoint "https://wac.contoso.com" "msft.sme.containers" -Feed "https://aka.ms/sme-extension-feed"
# Install an extension (install a specific version)
Install-Extension "https://wac.contoso.com" "msft.sme.certificate-manager" "0.133.0"
# Uninstall-Extension
Uninstall-Extension "https://wac.contoso.com" "msft.sme.containers"
# Update-Extension
Update-Extension "https://wac.contoso.com" "msft.sme.containers"
手記
PowerShell を使用して Windows Admin Center 拡張機能を変更するには、ゲートウェイ管理者である必要があります。
その他の参照
- クラスター に高可用性 Windows Admin Center ゲートウェイをデプロイする
- Cloud Shell を使用して Azure に Windows Admin Center ゲートウェイをデプロイする