Update properties on Sub-Connections

Update properties on Sub-Connections

avatar

Hello,

I have a bunch of RDPConfigured entries with PowerShellRemoteConsole sub-connections. I recently update all the RDPConfigured entires to use $INFORMATION_MACHINE_NAME$.$MACHINE_DOMAIN$ as the Host as we have multiple domains where its easier to pull in host/domain from information than manually updating each host using the following script:
$sessions = Get-RDMSession | 
where {$_.ConnectionType -eq "RDPConfigured"}
foreach ($session in $sessions) {
    $session.Host = 'INFORMATION_MACHINE_NAME$.$MACHINE_DOMAIN$'
    Write-Host "Name: $($session.Name) - Host: $($session.Host)"
    Set-RDMSession $session
}
Write-Host 'Done!'
Update-RDMUI

I'd like to do something similar with all my sub-connections to these entries, updating the host on those to be $PARENT_INFORMATION_MACHINE_NAME$.$PARENT_MACHINE_DOMAIN$. Is there a way to easily call to those sub-connections? I tried using PowerShellRemoteConsole in my where statement, however that doesn't seem to allow child items to be changed.
Thanks in advance!

All Comments (4)

avatar

Hello,

I guess something like this should work:

$parent = Get-RDMSession | where ConnectionType -eq "RDPConfigured"
$child =  $parent.SubConnections | where {$_.ConnectionType -eq "PowerShellRemoteConsole"}
foreach ($session in $child)
{
 $session.Host = '$PARENT_INFORMATION_MACHINE_NAME$.$PARENT_MACHINE_DOMAIN$'
 Set-RDMSession $parent -refresh
}

Please create always a backup before you run such scripts!

Regards,
Min

avatar

Hi Min,

Sorry for the late response. Your script doesn't seem to update the results. The following vars both pull back results as expected

$parent = Get-RDMSession | where ConnectionType -eq "RDPConfigured"
$child =  $parent.SubConnections | where {$_.ConnectionType -eq "PowerShellRemoteConsole"}

The foreach statement doesn't seem to be updating the Host (or anything as far as I can tell). I wonder if the PSRemote Host line is set as a different name than the RDP Host?

avatar

Figured this one out.
I ended up using Advance Search to select all my PSRemote options, then Batch Edited them all with a Powershell script:

$connection.Host = '$PARENT_INFORMATION_MACHINE_NAME$.$PARENT_MACHINE_DOMAIN$'
$RDM.Save();

Thanks!

avatar

Hello,

thanks for your feedback! I just updated the script above - it should work now - in case that you'll need it at a later time again 😉

Regards,
Min