logo

The ConnectWise Control forum has moved to ConnectWise University! This forum has been locked and is in read-only mode. Click here for instructions on how to access the new forum.

Welcome Guest! You can not login or register.

Notification

Icon
Error

Options
Go to last post Go to first unread
mazedecoder  
#1 Posted : Monday, June 11, 2018 1:06:02 PM(UTC)
mazedecoder


Rank: Guest

Joined: 5/25/2018(UTC)
Posts: 1
Man
Switzerland
Location: Aargau

Hi folks

We have about 1000 clients in our environment.
It happens a lot that a device needs to be reinstalled, what generates a new session-entry with the same name...
ConnectWise told me that there is no automation for that process (really??!!).
I really hate duplicate entries no matter in which system.

How can we end/delete a session over powershell oder cmd?
All we want is to create a script where we can enter the session name, and it should delete that specific session.
We already have such a script to remove a specific computer from DNS, SCCM, AD, etc, we would like to do that for ConnectWise Control too.

Thanks in advance and best regards

Silas

Edited by user Monday, June 11, 2018 1:08:29 PM(UTC)  | Reason: Not specified

Scott  
#2 Posted : Tuesday, June 12, 2018 12:09:25 PM(UTC)
Scott


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 3/28/2014(UTC)
Posts: 2,862
United States

Thanks: 3 times
Was thanked: 351 time(s) in 303 post(s)
We don't really expose that kind of functionality on the clientside directly, but you could pretty easily create an Extension that can be invoked via Invoke-WebRequest which would accept the session's name and then End any session(s) with the same name and no active connections.

The Extension would contain a WebService class with a single method similar to:
Code:

public void GetOfflineDuplicateSessionIDs(string sessionName)
{
	SessionManagerPool.Demux.GetSessions()
		.Where(_ => _.Name == sessionName)
		.Where(_ => _.ActiveConnections.Length == 0)
		.Select(s => s.SessionID)
		.ToArray()
		.ForEach(sessionID => 
			SessionManagerPool.Demux.AddSessionEvent(
				sessionID, 
				SessionEventType.EndedSession, 
				SessionEventAttributes.None, 
				"EndDuplicate", 
				""
			)
		);
}


Although you would probably want to add an API-token like parameter also to ensure that only you are allowed to execute the method.

You could then invoke the above-mentioned webservice method from powershell like:
Code:

Invoke-WebRequest -Uri http://subdomain.domain.com:8040/App_Extensions/EXTENSION_ID_HERE/Service.ashx/GetOfflineDuplicateSessionIDs -Method POST -ContentType "application/json" -Body "SESSION_NAME_HERE"


Which would execute the method and thus end any session named "SESSION_NAME_HERE" with no active connections (offline).
ScreenConnect Team
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.