PowerShell を使用して Windows Admin Center の設定を管理するUse PowerShell to manage Windows Admin Center settings

複数の Windows Admin Center サーバーを持つ大規模な組織の場合は、PowerShell を使用して、一度に複数のサーバーの接続と拡張機能の一覧を構成できます。If you have a large organization with multiple Windows Admin Center servers, you can use PowerShell to configure the list of connections and extensions on multiple servers at a time.

PowerShell を使用して (タグを使って) 接続をインポートまたはエクスポートするUse PowerShell to import or export your connections (with tags)

# 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 explictly in the imported file using the -prune switch parameter 
Import-Connection "https://wac.contoso.com" -fileName "WAC-connections.csv" -prune

接続をインポートする場合の CSV ファイルの形式CSV file format for importing connections

CSV ファイルの形式は、4 つの見出し "name","type","tags","groupId" で始まり、新しい行に各接続が続きます。The format of the CSV file starts with the four headings "name","type","tags","groupId", followed by each connection on a new line.

name は接続の FQDN ですname is the FQDN of the connection

type は接続の種類です。type is the connection type. Windows Admin Center に含まれる既定の接続については、次のいずれかを使用します。For the default connections included with Windows Admin Center, you will use one of the following:

接続の種類Connection type 接続文字列Connection string
Windows ServerWindows Server msft.sme.connection-type.servermsft.sme.connection-type.server
Windows 10 PCWindows 10 PC msft.sme.connection-type.windows-clientmsft.sme.connection-type.windows-client
フェールオーバー クラスターFailover Cluster msft.sme.connection-type.clustermsft.sme.connection-type.cluster
ハイパーコンバージド クラスターHyper-Converged Cluster msft.sme.connection-type.hyper-converged-clustermsft.sme.connection-type.hyper-converged-cluster

tags はパイプで区切られます。tags are pipe-separated.

groupId は共有接続に使用されます。groupId is used for shared connections. これを共有接続にするには、この列の値 global を使用します。Use the value global in this column to make this a shared connection.

注意

共有接続の変更はゲートウェイ管理者に限定されています。ユーザーは PowerShell を使用して、自分の個人用接続リストを変更できます。Modifying the shared connections is limited to gateway administrators - any user can use PowerShell to modify their personal connection list.

接続をインポートする場合の CSV ファイルの例Example CSV file for importing connections

"name","type","tags","groupId"
"myServer.contoso.com","msft.sme.connection-type.server","hyperv"
"myDesktop.contoso.com","msft.sme.connection-type.windows-client","hyperv"
"teamcluster.contoso.com","msft.sme.connection-type.cluster","legacyCluster|WS2016","global"
"myHCIcluster.contoso.com,"msft.sme.connection-type.hyper-converged-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"

RDCman 接続をインポートするImport RDCman connections

次のスクリプトを使用して、RDCman 内の保存されている接続をファイルにエクスポートします。Use the script below to export saved connections in RDCman to a file. 次に、Windows Admin Center にファイルをインポートし、タグを使用して RDCMan グループの階層を維持することができます。You can then import the file into Windows Admin Center, maintaining your RDCMan grouping hierarchy using tags. お試しください。Try it out!

  1. 次のコードをコピーし、PowerShell セッションに貼り付けます。Copy and paste the code below into your PowerShell session:

    #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 WAC
     }
     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 wish to export the new .csv file. If 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"
    }
    
  2. .CSV ファイルを作成するには、次のコマンドを実行します。To create a .CSV file, run the following command:

    RdgToWacCsv -RDGfilepath "path\to\myRDCManfile.rdg"
    
  3. 結果の .CSV ファイルを Windows Admin Center にインポートすると、すべての RDCMan グループ階層が接続リストのタグで表されます。Import the resulting .CSV file in to Windows Admin Center, and all your RDCMan grouping hierarchy will be represented by tags in the connection list. 詳細については、「PowerShell を使用して (タグを使って) 接続をインポートまたはエクスポートする」を参照してください。For details, see Use PowerShell to import or export your connections (with tags).

PowerShell を使用して Windows Admin Center の拡張機能を管理するManage Windows Admin Center extensions with PowerShell

# 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 の拡張機能を変更するには、ゲートウェイ管理者である必要があります。You must be gateway administrator to modify Windows Admin Center extensions with PowerShell.

関連項目See also