Powershell scripnt Connection has invalid group specified

Powershell scripnt Connection has invalid group specified

avatar

I have a powershell script that adds news session that throws the following error

Connection has invalid group specified

This can happen if a folder structure is there or not. Any ideas on how to tell the scripting to create the group if this error is discovered? I have tried the following code to add a group, but it does not show up in RDM.

$ServerEntry = New-RDMSession -Name $Group -Type Group -Group $Group


Update-RDMUI -verbose

EDIT:

I think what I need to do here is be able to capture the error, and create the group. How can I capture that specific error or message? try/catch is not identifying this as an error.

All Comments (7)

avatar

Hello,

To better assist you, could you please provide the following details:
- The version of PowerShell you are using?
- The version of Remote Desktop Manager (RDM) involved?
- Are you using the full path of your folder in the script?

These details will help in identifying the potential causes of the issue and to guide you more effectively.

Best regards,

Patrick Ouimet

avatar

I am using the latest versions of the powershell modules and Remote desktop manager. I am not using any paths in the script.

Here is the script

#check if RDM PS module is installed
if(-not (Get-Module Devolutions.PowerShell -ListAvailable)){
Install-Module Devolutions.PowerShell -Scope CurrentUser
}

Import-Module Devolutions.PowerShell
Start-RDMInstance

# Adapt the data source name
$ds = Get-RDMDataSource -Name "Local Data Source"
Set-RDMCurrentDataSource $ds

$Group = "Cloud\SAVREDHEART\NON-PROD"


$ServerEntry = New-RDMSession -Name $Group -Type Group -Group $Group
Set-RDMSession $ServerEntry
Update-RDMUI -verbose

avatar

Hello Joe,

Thank you for this feedback.

Could you check the version of your PowerShell and the Version of your Devolutions.PowerShell module?
I tried this with VS Code, and I got the same issue as yours.
Then I tried using the terminal, and it worked.

This is the script I was using to create a sub-folder:

$server = New-RDMSession -Name "non-prod2" -Group "Cloud\SAVREDHEART\NON-PROD" -Type "Group"; Set-RDMSession $server
$server


Best regards,

Patrick Ouimet

avatar

I am running from the terminal as well. The module folder is 2024.1.4 for the version.

I am also running the script from a terminal window for powershell 7.

avatar

Hello joecarmon,

After investigation, if you have multiple subfolders under a path, you must specify the full path with the new folder you want to create.

$server = New-RDMSession -Name "non-prod2" -Group "Cloud\SAVREDHEART\NON-PROD\non-prod2" -Type "Group"; Set-RDMSession $server
$server

Patrick Ouimet

avatar

Ok. So that is working, now how do I capture the error message? I get the same message with I attempt to create a server, RDPConnection, or SSHShell type connection as well. I need to be able to handle the error message no matter what type I am attempting to create.

avatar

Hello Joe,

Did you have a look at the Get-Help for this Cmdlet?

NAME
New-RDMSession

SYNOPSIS
Create a new session instance.


SYNTAX
New-RDMSession [[-Name] <String>] [[-Type] <ADConsole | AddOn | Agent | AppleRemoteDesktop | ApplicationTool | Aws | Azure | AzureQueueStorage | AzureStorage
| AzureTableStorage | BeyondTrustPasswordSafeConsole | ChromeRemoteDesktop | CitrixWeb | CommandLine | Computer | Contact | ControlUp | Credential | Customer
| CyberArkJump | CyberArkPSM | Dameware | Database | DataEntry | DataReport | DataSource | DeskRoll | Desktone | DevolutionsProxy | Document | DropBox |
FileExplorer | Ftp | FtpNative | Gateway | Group | Host | HpRgs | HyperV | ICA | IDrac | Ilo | IntelAMT | InventoryReport | Iterm | LogMeIn | PCAnywhere |
PlayList | PortForward | PowerShell | PowerShellRemoteConsole | ProxyTunnel | PSExec | Putty | Radmin | RDCommander | RDPConfigured | RDPFilename |
ResetPassword | S3 | Scp | ScreenConnect | ScreenHero | ScriptDashboard | SecureCRT | Serial | SessionTool | Sftp | Sheet | SkyDrive | SNMPReport |
Spiceworks | Splunk | SSHShell | SSHTunnel | Sync | TeamViewer | TeamViewerConsole | Telnet | TemplateGroup | TerminalConsole | TFtp | VirtualBox | VirtualPC
| VMRC | VMWare | VMWareConsole | VNC | VPN | Wayk | WaykDenConsole | WebBrowser | WebDav | WindowsAdminCenter | WindowsVirtualPC | XenServer | XWindow>]
[[-Group] <String>] [-DocumentAttachment <PSConnectionAttachment>] [-DocumentFileName <String>] [[-Host] <String>] [-SetSession] [-TemplateID <Guid>]
[-ForcePromptAnswer <Cancel | No | Yes>] [<CommonParameters>]


DESCRIPTION
Create a new session instance. The instance has not yet been saved. Assign the result to a variable then call "Set-RDMSession $s" to save the session.




PARAMETERS
-DocumentAttachment [<PSConnectionAttachment>]
New document attachement.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-DocumentFileName [<String>]
New document file name.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-ForcePromptAnswer [<DialogResult[]>]
Switch to use with caution. It will automatically answer prompt asking yes/no, yes/no/cancel, or ok/cancel questions. In case of multiple prompts,
multiple values can be passed to this parameter. Here are the accepted values:
- Yes: Accept the prompt. Cover the OK and Automatic value.
- No: Refuse the yes/no/cancel prompt. Cancel is the fallback option if there is not an option No.
- Cancel: Cancel the yes/no/cancel prompt. No is the fallback option if there is not an option Cancel.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Group [<String>]
Session group.

Required? false
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Host [<String>]
New Session host.

Required? false
Position? 4
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Name [<String>]
New PSSession name.

Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false

-SetSession
Save the session in the current data source.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-TemplateID [<Guid>]
Create PSSession from template.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Type [<String>]
New session kind. Must be on of the following:


"ADConsole", "AddOn", "AppleRemoteDesktop", "ApplicationTool", "Aws", "Azure", "AzureQueueStorage", "AzureStorage", "BeyondTrustPasswordSafeConsole",
"ChromeRemoteDesktop"CitrixWeb", "CommandLine", "Computer", "Contact", "ControlUp", "Credential", "Customer", "CyberArkJump", "CyberArkPSM", "Dameware",
"Database", "DataEntry", "DataReport", "DataSource", "DeskRoll", "Desktone", "DevolutionsProxy", "Document", "DropBox", "FileExplorer", "Ftp",
"FtpNative", "Gateway", "Group", "Host", "HpRgs", "HyperV", "ICA", "IDrac", "Ilo", "IntelAMT", "InventoryReport", "Iterm", "LogMeIn", "PCAnywhere",
"PlayList", "PortForward", "PowerShell", "PowerShellRemoteConsole", "ProxyTunnel", "PSExec", "Putty", "Radmin", "RDCommander", "RDPConfigured",
"RDPFilename", "ResetPassword", "S3", "Scp","ScreenConnect", "ScreenHero", "ScriptDashboard", "SecureCRT", "Serial", "SessionTool" , "Sftp" , "Sheet" ,
"SkyDrive", "SNMPReport"),"Spiceworks", "Splunk", "SSHShell", "SSHTunnel", "Sync", "TeamViewer", "TeamViewerConsole", "Telnet",""TemplateGroup",
"TerminalConsole", "TFtp","VirtualBox", "VirtualPC", "VMRC", "VMWare", "VMWareConsole", "VNC", "VPN", "Wayk", "WaykDenConsole", "WebBrowser", , "WebDav",
"WindowsAdminCenter", "WindowsVirtualPC", "XenServer", "XWindow"


Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).

INPUTS
None



OUTPUTS
RemoteDesktopManager.PowerShellModule.PSOutputObject.PSConnectionNew session created object



NOTES


For more information, type "Get-Help New-RDMSession -detailed". For technical information, type "Get-Help New-RDMSession -full".

------------------EXAMPLE------------------

PS C:\> $session = New-RDMSession -Name "New Session" -Host "myServer" -Type "RDPConfigured";Set-RDMSession $session

Create & save new session.

RELATED LINKS
Get-RDMDataSource
Set-RDMDataSource
Set-RDMSession
Remove-RDMSession

Best regards,

Patrick Ouimet