avatar
Hussin Hassan
0

Codes

5

Answers

Code compilers

Top answers

0
javascript
February-07-2023
wmic path softwarelicensingservice get OA3xOriginalProductKey
0
param
January-24-2023
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"
}
0
load module
January-24-2023
# 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
0
import module
January-24-2023
# 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
0
Windows Admin Center
January-24-2023
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/.