Skip to content

About

PowerShell wrapper for the ConnectWise Manage REST API

Resources

Code of conduct

Contributing

Security policy

Stars

127 stars

Watchers

20 watching

Forks

Repository files navigation


logo
ConnectWise Manage REST API

A comprehensive PowerShell wrapper for the ConnectWise Manage REST API

CI Codacy Badge Gallery Downloads License Donate

Features β€’ Installation β€’ Quick Start β€’ Functions β€’ Examples β€’ Wiki β€’ Contributing


πŸ“‹ Table of Contents

✨ Features

This module makes it easy to leverage PowerShell to automate tasks in ConnectWise Manage:

  • 250+ Cmdlets covering all major API endpoints
  • Automated Pagination for large result sets
  • Advanced Filtering using ConnectWise condition syntax
  • Retry Logic for throttling and transient errors (writes are retried only on 429, so a retry never creates a duplicate)
  • Object Output that works with the PowerShell pipeline (Where-Object, Select-Object, Export-Csv)
  • Built-in Help with examples for every function (Get-Help <function> -Full)
  • Cross-Platform: PowerShell 7 on Windows, Linux and macOS, and Windows PowerShell 5.1

πŸ“¦ Installation

From PowerShell Gallery (Recommended)

Install-Module 'ConnectWiseManageAPI' -Scope CurrentUser

Update to Latest Version

Update-Module 'ConnectWiseManageAPI'

Note: If you're having issues accessing the PowerShell Gallery, check out this repair script

πŸš€ Quick Start

Prerequisites

Important: As of August 14, 2019, ConnectWise requires a Client ID to interact with the API.

Authentication

# Connect to ConnectWise Manage
Connect-CWM -Server 'na.myconnectwise.net' `
            -Company 'YourCompany' `
            -pubkey $publicKey `
            -privatekey $privateKey `
            -clientId $clientId

For detailed authentication options and setup, see the Authentication Wiki.

πŸ’‘ Usage Examples

Working with Tickets

# Get all open tickets
Get-CWMTicket -condition "status/name='Open'" -all

# Create a new ticket
$ticketParams = @{
    summary = 'Issue reported via PowerShell'
    board = @{ id = 1 }
    company = @{ id = 123 }
    status = @{ id = 456 }
}
New-CWMTicket @ticketParams

# Update one field of a ticket
Update-CWMTicket -id 12345 -Operation replace -Path status -Value @{ id = 789 }

# Update several fields in one request
Update-CWMTicket -id 12345 -PatchOperations @(
    @{ op = 'replace'; path = 'status'; value = @{ id = 789 } }
    @{ op = 'replace'; path = 'summary'; value = 'Updated from PowerShell' }
)

Working with Companies

# Search for companies by type (types is a list, so use -childConditions)
Get-CWMCompany -childConditions "types/name='Partner'" -all

# Get company with specific ID
Get-CWMCompany -id 123

# Create a new company (look up the type ID with Get-CWMCompanyType)
$companyParams = @{
    identifier = 'ACME'
    name = 'ACME Corporation'
    types = @(@{ id = 1 })
}
New-CWMCompany @companyParams

Working with Time Entries

# Get time entries for a date range
Get-CWMTimeEntry -condition "timeStart > [2024-01-01] and timeStart < [2024-01-31]" -all

# Create a new time entry
$timeParams = @{
    company = @{ id = 123 }
    chargeToType = 'ServiceTicket'
    chargeToId = 12345
    timeStart = (Get-Date) | ConvertTo-CWMTime -Raw
    timeEnd = (Get-Date).AddHours(2) | ConvertTo-CWMTime -Raw
    member = @{ identifier = 'JDoe' }
}
New-CWMTimeEntry @timeParams

More examples available in the Examples directory.

πŸ”„ Upgrading to 0.5.0

0.5.0 has breaking changes. The main ones:

  • PowerShell 5.1 or later is required (was 3.0).
  • The module always uses the server's current API version. Connect-CWM -Version is removed; remove it from your scripts.
  • New-CWMTicket no longer takes -Version, -VersionAutomatic, -project, -phase, -wbsCode, -locationId, -businessUnitId, -dateEntered or -enteredBy. Create project tickets with New-CWMProjectTicket.
  • Connect-CWM -MemberID now really impersonates the member (0.4.16 silently used the API key).
  • A few parameters and aliases the API did not accept were removed, some route ids are now mandatory, and positional binding shifted on five functions. Use named parameters.

See the CHANGELOG for the full list and migration hints.

πŸ”§ Troubleshooting

PowerShell 7.4+ and "Cannot follow an insecure redirection"

On PowerShell 7.4 and later, create and update calls (New-CWM*, Update-CWM*) against some ConnectWise-hosted servers can fail with "Cannot follow an insecure redirection by default". The server's response carries an http:// Location header, usually on a request it has already processed, so the record may exist even though you saw an error.

Connect with the opt-in -AllowInsecureRedirect switch:

Connect-CWM -Server 'na.myconnectwise.net' -Company 'YourCompany' `
            -pubkey $publicKey -privatekey $privateKey -clientId $clientId `
            -AllowInsecureRedirect

With the switch, PowerShell accepts that response, but the module never follows a redirect on a create or update (nothing is sent over http). If the server sends a real redirect, you get an error saying it was not followed and that the record may already exist. The switch has no effect on Windows PowerShell 5.1 or PowerShell 7.0-7.3, which do not raise this error. Whenever you see either error, check whether the record was created before you retry.

πŸ“š Available Functions

The module includes 250+ cmdlets organized by functional area:

Category Functions
Service Tickets, Service Boards, Ticket Notes, Configurations, Knowledge Base, Service Templates
Company Companies, Contacts, Sites, Teams
Time Time Entries, Time Sheets
Project Projects, Phases, Team Members, Project Tickets
Finance Agreements, Billing, Invoices
System Members, Audit Trail, Documents
Sales Opportunities, Activities
Marketing Marketing Groups
Procurement Products, Inventory, Purchase Orders
Schedule Calendar Entries, Holidays

For a complete list of available functions, see ConnectWiseManageAPI_Functions.md.

πŸ“‹ Requirements

  • PowerShell Version: PowerShell 5.1 or later. PowerShell 7.4+ is recommended (Windows, Linux and macOS); Windows PowerShell 5.1 is still supported. Both are tested on every change.
  • ConnectWise Manage: Active instance with API access
  • API Credentials: Public/Private API keys and Client ID
  • Dependencies: None (self-contained module)

πŸ”’ Security

For reporting security vulnerabilities, please see our Security Policy.

🀝 Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated!

How to Contribute

  1. Star this repository ⭐ - It helps others discover the project
  2. Report bugs - Use the bug report template
  3. Suggest features - Use the feature request template
  4. Submit pull requests - See our Contributing Guide
  5. Share your work - Show us what you've built!

Want to share something you created using the module? Submit it to be featured as a Community Package.

πŸ“– Tutorials & Blog Posts

In-depth tutorials on christaylor.codes:

Tutorial Description
Introducing ConnectWiseManageAPI Module overview, architecture, and key features
Getting Started Authentication, setup, and first API calls
Advanced Automation Complex workflows and real-world automation scenarios
Best Practices Production deployment patterns and performance tips

πŸ’¬ Support

Getting Help

Show Your Support

If this project has helped you, please consider:

Your support enables continued development and maintenance of this project!

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • ConnectWise for providing the Manage API
  • The MSPGeek community for feedback and support
  • All contributors who have helped improve this module

⬆ back to top

Made with ❀️ by Chris Taylor

About

PowerShell wrapper for the ConnectWise Manage REST API

Resources

Code of conduct

Contributing

Security policy

Stars

127 stars

Watchers

20 watching

Forks

Releases

Packages

Contributors

Languages