Codes
Answers
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"
}
">#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"
}
# 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 using the -prune switch parameter
Import-Connection "https://wac.contoso.com" -fileName "WAC-connections.csv" -prune
# 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 using the -prune switch parameter
Import-Connection "https://wac.contoso.com" -fileName "WAC-connections.csv" -prune
From the Start menu, select Windows Admin Center. Or type Windows Admin Center in the search bar and then select it from the search results. Windows Admin Center opens in your default browser with the URL: https://localhost:6516/. Alternatively, you can also start it from your desired browser by entering https://localhost:6516/.
Questions
Answers
Answer accepted
Users
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us