Finally an Autotask PowerShell module

It has been quite a while since last I posted an article here. But now I feel I really have something useful to share. A colleague and I have written and published an Autotask PowerShell module. You can find it on PowerShell Gallery. The code is published on Github.

From the PowerShell Gallery module description:

“This module consists of 2 parts: A normal script module and a nested, dynamic module that is created when you authenticate to the Autotask Web Services API. The base module queries the API for detailed information about all available Autotask entities and creates functions that let you write PowerShell scripts in PowerShell ISE or Visual Studio Code with full IntelliSense support. Dynamic functions are cached to disk and updated whenever the base module or the API version changes. See the Project Site for more details.”

You can install the module directly from PowerShell Gallery:

Install-Module -Name Autotask

To use it you load it as any normal module and connect to Autotask:

Import-Module Autotask
# Enter your username and password to Autotask
$Credential = Get-Credential
Connect-AutotaskWebAPI -Credential $Credential

The first time you connect to Autotask our connect script will download information about every Autotask entity from the SOAP API and generate PowerShell functions for every entity. The functions are saved to disk for re-use, as hitting the API once for every possible entity (there are 106 entities in the current API version) takes a while. We check the version of the Autotask module and the API everytime you run Connect-AutotaskWebAPI and update the disk cache should a new version be available.

The generated functions are loaded as a dynamic module and allows you to do things like

$Account = Get-AtwsAccount -Name 'Company Name'
$Contracts = Get-AtwsContract -AccountId $Account.Id -ContractType 'Recurring Service'
$DueDate = (Get-Date).AddDays(3)
$Title = 'This is an API test'
$Ticket = New-AtwsTicket -QueueId 'Queue Name' -AccountId $Account.Id -DueDateTime $DueDate -Priority Medium -Status New -Title $Title
Write-Output $Ticket.TicketNumber

Anyone who has tried to work with the Autotask API with code from my previous posting should appreciate just how much easier to work like this! The example also show a feature we find useful: Quite a few properties on Autotask entities are picklists. When you pass an entity object to the SOAP API you have to provide the Integer index of a picklist value. With our PowerShell module all picklists are retrieved from Autotask and added to a parameters ValidateSet. This way you can use IntelliSense to select a picklist value by label. In my example you can see this for -QueueId, -Priority and -Status.

There is a lot more information included as comment based help in the dynamic functions, so to get more information about how to use Get-AtwsTicket you just type

Get-Help Get-AtwsTicket

More examples will be posted on the project site as time allows, but we release the module now as it is usable as it is.

Happy Autotasking!