Example ConnectWise Automate C# Plugins

While beginning to develop the AD Recycle Bin plugin for ConnectWise Automate (LabTech), it was a daunting task to find good examples of plugin code outside of the ConnectWise Developer documentation and the example plugin posted by Greg Buerk posted to Labtech Geek. The developer documentation while giving a good base of knowledge for the API’s and interfaces, it doesn’t give a good picture of what different types of plugins should look like. Greg’s example, while a great example of the different things you can do with a plugin, it’s only written in VB.NET and has so many different examples that it can be difficult to parse what’s needed for just one screen, such as a Computer Screen tab. My goal for this series of GitHub repositories is to provide easy to follow and documented plugin examples written in C#.

Unable to Open vSphere Client

If you haven’t kept your vSphere Client up to date then it’s possible that updates from Microsoft to the .NET framework have caused an issue where you are unable to open vSphere Client, receiving the following message:

The type initializer for VirtualInfrastructure.Utils.HttpWebRequestProxy’ threw an exception.

If this is the case you have two solutions to get it going again. The first is the easiest solution, updating to the latest vSphere Client. If you would like to stay at the current vSphere Client version then there is a solution to problem.

Fixing Your vSphere Client

In Explorer, navigate to:


In this folder there should be a file called system.dll, copy this file to the following folder:

C:\Program Files (x86)\VMware\Infrastructure\Virtual Infrastructure Client\Launcher\lib

Notes: On 32-bit machines it will be “Program Files” instead of “Program Files (x86)”. You may have to create the lib folder if it doesn’t exist.

In the “Launcher” folder there is a file called “VpxClient.exe.config”. Open this file with a text editor. Near the end of the file before the </configuration> tag add the following lines and save the file:

<developmentMode developerInstallation=”true”/>

Now open the System properties from the control panel, then Advanced System Settings. Inside of the Advanced System Settings you will now need to launch the Environment Variables editor.

Add the following environment variable:

Variable: DEVPATH

Value: C:\Program Files (x86)\VMware\Infrastructure\Virtual Infrastructure Client\Launcher\Lib

Note: On 32-bit machines it will be “Program Files” instead of “Program Files (x86)”.

Now you should be able to launch your vSphere Client without an issue.

Connect to Exchange Online with Powershell

In my previous post I talked about using Powershell to connect to Office 365 to manage the service. Using that method you will be able to manage user accounts and other settings that only apply to the Office 365 service itself. If you would like to connect to Exchange Online with Powershell to manage users’ mailboxes then Microsoft also provides cmdlets that allow you to perform these tasks.


Install Microsoft .NET Framework 4.5.x

Install Windows Management Framework 3.0 or 4.0

Launch Powershell

You will want to right click Powershell and use Run as Administrator.

Office 365 Credentials

Now that you have the Powershell window ready to go, issue the following command in the Powershell window. Once you do, it will launch a window requesting your username and password for Office 365.

$cred = Get-Credential

Getting Office 365 Credential

Connecting to Exchange Online

With the credential stored you can now use it to connect to the Exchange Online service.

$exchSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri “https://outlook.office365.com/powershell-liveid/” -Credential $credential -Authentication “Basic” -AllowRedirection

If authentication was successful, you are now connected to your Exchange Online organization and can manage your service from there.

Disconnecting from Exchange Online

Once you’ve finished the Exchange Online management tasks in Powershell you will then need to free up your session by removing it.

Remove-PSSession $exchSession

Connecting to Exchange Online with Powershell

Page 1 Page 2 Page 3 Page 7