Hello,
I'm running into an issue in my attempt to set a password for a session.
I am using the SetRDMSessionPassword for an RDP session.
Everything seems to work fine except I get "WARNING: Connection not found." when using the following code:
$sessionName = "Instructor VM"
$ipAddr = $($instVMdata.IPAddr)
$userName = $($instVMdata.Username)
$password = $($instVMdata.Password)
$securestring = ConvertTo-securestring $password -asplaintext -force
$sessionInstVM = New-RDMSession -Group $classGroupName -Name $sessionName -Host $ipAddr -Type RDPConfigured
$sessionInstVM.SortPriority = "10"
$sessionInstVM.ImageName = "SYS_Host"
$sessionInstVM.RDP.Domain = $domain
$sessionInstVM.RDP.Username = $userName
$sessionID = $sessionInstVM.ID
Set-RDMSession $sessionInstVM
Set-RDMSessionPassword -ID $sessionID -Password $securestring -Refresh
The session gets created just fine. I can see it, but it never assigns the password to the session.
What could I be doing wrong?
Hi,
I recommend to use the session parameters because it modifies the object itself. When you use the ID parameters, the cmdlet tries to find to the session in the data source.
Ex with the session parameters:$sessionName = "Instructor VM"$ipAddr = $($instVMdata.IPAddr)$userName = $($instVMdata.Username)$password = $($instVMdata.Password)$securestring = ConvertTo-securestring $password -asplaintext -force$sessionInstVM = New-RDMSession -Group $classGroupName -Name $sessionName -Host $ipAddr -Type RDPConfigured$sessionInstVM.SortPriority = "10"$sessionInstVM.ImageName = "SYS_Host"$sessionInstVM.RDP.Domain = $domain$sessionInstVM.RDP.Username = $userNameSet-RDMSessionPassword -Session $sessionInstVM -Password $securestringSet-RDMSession -Session $sessionInstVM -Refresh
If you still want to use the ID parameters. You need to call Update-RDMUI before Set-RDMSessionPassword because when you use Set-RDMSession you need to explicitly call a refresh otherwise the next cmdlets called won't be able to find a new connection created with PowerShell.
Ex with the ID parameters:$sessionName = "Instructor VM"$ipAddr = $($instVMdata.IPAddr)$userName = $($instVMdata.Username)$password = $($instVMdata.Password)$securestring = ConvertTo-securestring $password -asplaintext -force$sessionInstVM = New-RDMSession -Group $classGroupName -Name $sessionName -Host $ipAddr -Type RDPConfigured$sessionInstVM.SortPriority = "10"$sessionInstVM.ImageName = "SYS_Host"$sessionInstVM.RDP.Domain = $domain$sessionInstVM.RDP.Username = $userName$sessionID = $sessionInstVM.IDSet-RDMSession $sessionInstVMUpdate-RDMUISet-RDMSessionPassword -ID $sessionID -Password $securestring -Refresh
Best regards,
Olivier Désalliers