Convert Terminals (Robert Chartier) favorites file to mRemoteNG config file

Attempting to convert Terminals (Robert Chartier) favorites file to mRemoteNG config file. Both files are XML. I need to loop through the favorites file that looks like this (C:TemptempTerminals.xml):

<?xml version="1.0" encoding="utf-8"?>
<favorites>
 <favorite>
   <protocol>RDP</protocol>
   <port>3389</port>
   <serverName>first.machine.local</serverName>
   <url>rdp://first.machine.local:3389/</url>
   <name>First Machine</name>
   <notes />
   <tags>FM</tags>
   <newWindow>False</newWindow>
   <toolBarIcon />
   <bitmapPeristence>RDP</bitmapPeristence>
   <credential />
   <domainName />
   <desktopSize>AutoScale</desktopSize>
   <desktopSizeHeight>600</desktopSizeHeight>
   <desktopSizeWidth>800</desktopSizeWidth>
   <colors>Bit16</colors>
   <sounds>DontPlay</sounds>
   <redirectClipboard>True</redirectClipboard>
   <enableTLSAuthentication>True</enableTLSAuthentication>
   <enableNLAAuthentication>True</enableNLAAuthentication>
   <idleTimeout>240</idleTimeout>
   <overallTimeout>600</overallTimeout>
   <connectionTimeout>600</connectionTimeout>
   <shutdownTimeout>10</shutdownTimeout>
 </favorite>
</favorites>

And I need to add each of them to an empty mRemoteNG config file that looks like this (C:TemptempRemoteng.xml):

<?xml version="1.0" encoding="utf-8"?>
<mrng:Connections xmlns:mrng="http://mremoteng.org" Name="Connections" Export="false" 
      EncryptionEngine="AES" BlockCipherMode="GCM" KdfIterations="1000" 
      FullFileEncryption="false" Protected="<A really long value>" ConfVersion="2.6">
    < New nodes are to go here >
</mrng:Connections>

This is what each child node should look like:

<Node Name="<Name from favorite>" Type="Connection" Descr="" Icon="mRemoteNG" 
      Panel="General" Id="<Need new GUID here>" Username="_username_" Domain="_domain_" 
      Password="_password" Hostname="<serverName from favorite>" Protocol="RDP" 
      PuttySession="Default Settings" Port="3389" ConnectToConsole="false"
      UseCredSsp="true" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" 
      RDPAuthenticationLevel="NoAuth" RDPMinutesToIdleTimeout="0" />

(There’s actually a lot more attributes, I just truncated it for example)

I need to modify the Name, Hostname attributes and add a new GUID in the Id attribute.

This code, gives me the error “The specified node cannot be inserted as the valid child of this node, because the specified node is the wrong type.”

$terminals = Get-Content -Path "C:TemptempTerminals.xml"
$terminalsDoc = [xml]$terminals

$remoteNg = Get-Content -Path "C:TemptempRemoteng.xml"
$remoteNgDoc = [xml]$remoteNg

clear

# Accessing elements
$root = $terminalsDoc.favorites.ChildNodes

$childNode = $remoteNgDoc.ChildNodes[1]

foreach($node in $root) 
{
    $rootValue = $node.name
    $rootURI = $node.serverName

    $newNode = [xml]@"
    <Node Name="$($rootValue)" Type="Connection" Descr="" Icon="mRemoteNG" Panel="General" Id="$(New-Guid)" Username="_username_" Domain="_domain_" Password="_Password_" 
          Hostname="$($rootURI)" Protocol="RDP" PuttySession="Default Settings" Port="3389" ConnectToConsole="false" UseCredSsp="true" RenderingEngine="IE" ICAEncryptionStrength="EncrBasic" RDPAuthenticationLevel="NoAuth" RDPMinutesToIdleTimeout="0" />
"@
 $childNode.AppendChild($newNode)

}

Just having difficulty understanding handling of XML in PowerShell.

BTW, I tried using Import-CliXml on both files and am getting this error:

Import-CliXml : Element 'Objs' with namespace name 'http://schemas.microsoft.com/powershell/2004/04' was not found. Line 1, position 2.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật