Forum / Remote Desktop Manager - PowerShell Repository

Add session with powershell, update if exsist.

  • Create an Issue
  • Cancel

Hi

I made a script to create session from a excel sheet with all the information inside. This works perfectly, my problem is if the session already exist it create a duplicate. Can i get it to update the session if it's already there?

Or do i need to check for existence first with Get-RDMSession?

Clock4 yrs

Hello,

You need to check for its existence first. That's exactly what our own synchronizer does

Best regards,



Maurice Côté

signaturesignature

Clock4 yrs

How do i get it to update the session already there with the settings from the file. Does it need to have the id?

Clock4 yrs

I have a script that requests a company name. It then checks the sessions to see if a session with that name already exists.
Using If Else my script then either creates the group or retrieves information from the existing one.
You should be able to amend this to fit your needs.

$company = Read-Host "Enter a new company name and press ENTER to create a new client,"$nl"enter an existing company name (not case sensitive) and press ENTER to edit an exisiting client"$nl"or just press ENTER to exit"$nl

if ($company -ne "")
{
if ([bool](Get-RDMSession | where {($_.Name -eq $company) -and ($_.Kind -eq 'Group') -and ($_.Group -eq $company)}))
{
Write-Host $nl 'Company already exists, assigning variables' $nl
$domain = (Get-RDMSession | where {($_.Name -eq $company) -and ($_.Kind -eq 'Group') -and ($_.Group -eq $company)}).GroupDetails.Domain
}
Else
{
$domain = Read-Host 'Enter the netbios domain name (eg: eea) and press ENTER' $nl
}
}

Clock4 yrs

Hello,

@ThomasHansen, because the session ID is unique and is assigned at the creation, it will be preferable to check if a session already exist with the name like suggested by Paul Flint.

Best regards,



Érica Poirier

signaturesignature

Clock4 yrs