### Install AutotaskAPI Module Source: https://github.com/kelvintegelaar/autotaskapi/blob/master/README.md Installs the AutotaskAPI module from the PowerShell Gallery. This is the first step to using the module. ```powershell Install-Module AutotaskAPI ``` -------------------------------- ### Get Resources with SimpleSearch (Begins With) Source: https://github.com/kelvintegelaar/autotaskapi/blob/master/README.md Retrieves resources where a specific field begins with a given string. This uses the SimpleSearch syntax for convenience. ```powershell Get-AutotaskAPIResource -Resource Companies -SimpleSearch "companyname beginswith A" ``` -------------------------------- ### Get Resources with SimpleSearch Source: https://github.com/kelvintegelaar/autotaskapi/blob/master/README.md Retrieves resources using a simplified search syntax. This is suitable for single, straightforward filters. ```powershell Get-AutotaskAPIResource -Resource Companies -SimpleSearch "isactive eq $true" ``` -------------------------------- ### Get Resource by ID Source: https://github.com/kelvintegelaar/autotaskapi/blob/master/README.md Retrieves a specific resource (e.g., Companies) by its ID from the Autotask API. This is a basic GET request for a single item. ```powershell Get-AutotaskAPIResource -Resource Companies -ID 12345 ``` -------------------------------- ### Get Resources with JSON SearchQuery Source: https://github.com/kelvintegelaar/autotaskapi/blob/master/README.md Retrieves resources from the Autotask API using a JSON formatted SearchQuery. This allows for complex filtering with AND/OR logic. ```powershell Get-AutotaskAPIResource -Resource Companies -SearchQuery '{"filter":[{"op":"eq","field":"isactive","value":"true"}]}' ``` -------------------------------- ### Get Child Alerts for a Company Source: https://github.com/kelvintegelaar/autotaskapi/blob/master/README.md Retrieves all child alerts associated with a specific company ID. The -verbose flag can provide more detailed output. ```powershell Get-AutotaskAPIResource -Resource CompanyAlertsChild -ID 1234 -verbose ``` -------------------------------- ### Delete Data from API (DELETE) Source: https://github.com/kelvintegelaar/autotaskapi/blob/master/README.md Provides instructions and warnings for deleting data from Autotask using `Remove-AutotaskAPIResource`. It highlights the permanent nature of deletions and the importance of confirmation, showing examples of deleting a single company by ID and multiple companies based on a search. ```APIDOC DELETE/Remove data from API: > **WARNING** > You can and will delete actually data from your PSA instance. There is no recycle bin or restore function, if you defined faulty filters or used wrong IDs. Therefore all examples are permitted in execution by using -Confirm $false. If you copy and paste the lines, they won't be executed. If Confirm is not set, the Module won't delete data from Autotask. Delete the company with ID 1234. Each item in the object will be removed. Confirmation will be required. ```powershell Remove-AutotaskAPIResource -Resource Companies -ID 1234 -Confirm $false ``` `Remove-AutotaskAPIResource` also accept pipeline input. ```powershell Get-AutotaskAPIResource -Resource Companies -SimpleSearch 'Isactive eq true' | Remove-AutotaskAPIResource -Confirm $false ``` ``` -------------------------------- ### Update Data in Autotask (PATCH) Source: https://github.com/kelvintegelaar/autotaskapi/blob/master/README.md Details how to update existing resources in Autotask using `Set-AutotaskAPIResource`. It emphasizes using the PATCH method and removing unnecessary properties. Examples include updating a single ticket, closing multiple tickets, and changing web addresses for multiple companies. ```APIDOC PATCH/Update data in Autotask: To set existing companies, use the `Set-AutotaskAPIResource` function. This uses the Patch method so remember to remove any properties you do not want updated. ```powershell Set-AutotaskAPIResource -Body $body ``` Both `Set-AutotaskAPIResource` and `New-AutotaskAPIResource` accept pipeline input, for example, to change a title of a specific ticket: ```powershell $Ticket = Get-AutotaskAPIResource -Resource tickets -SimpleSearch "id eq 12345" ``` Or to close all tickets with the subject "Nope!" ```powershell $TicketList = Get-AutotaskAPIResource -Resource Tickets -SimpleSearch "title eq Nope!" $TicketList | ForEach-Object { $_.status = "12" } $TicketList | Set-AutotaskAPIResource -Resource Tickets ``` Or a one-liner to change all companies webaddresses to "google.com" ```powershell Get-AutotaskAPIResource -Resource Companies -SimpleSearch 'Isactive eq true' | ForEach-Object {$_.Webaddress = "www.google.com"; $_} | Set-AutotaskAPIResource -Resource Companies ``` ``` -------------------------------- ### Get Specific Child Alert for a Company Source: https://github.com/kelvintegelaar/autotaskapi/blob/master/README.md Retrieves a specific child alert for a given company ID, identified by its ChildID. This allows for targeted retrieval of child alerts. ```powershell Get-AutotaskAPIResource -Resource CompanyAlertsChild -ID 29683578 -ChildID 7 ``` -------------------------------- ### Create Data in Autotask (POST) Source: https://github.com/kelvintegelaar/autotaskapi/blob/master/README.md Explains how to create new resources in Autotask using the `New-AutotaskAPIResource` function. It covers generating a default body with `New-AutotaskBody`, creating an empty body, and retrieving picklist options. ```APIDOC POST/Create data in Autotask: To create a new company, we can either make the entire body ourselves, or use the `New-AutotaskBody` function. ```powershell $Body = New-AutotaskBody -Resource Companies ``` This creates a body for the model Company. Definitions can be tab-completed. The body will contain all expected values. If you want an empty body instead, use: ```powershell $Body = New-AutotaskBody -Resource Companies -NoContent ``` If you only want to know what picklist options are available, for a specific resource use the following: ```powershell (New-AutotaskBody -Resource Tickets -NoContent).status ``` This will print a list with all possible options. After setting the values for the body you want, execute: ```powershell New-AutotaskAPIResource -Resource Companies -Body $body ``` ``` -------------------------------- ### Combine Data with Microsoft Teams Source: https://github.com/kelvintegelaar/autotaskapi/blob/master/README.md Demonstrates how to combine Autotask project data with Microsoft Teams to create a team for each open project and assign a team lead. Requires the MicrosoftTeams module. ```powershell Import-Module MicrosoftTeams Connect-MicrosoftTeams Add-AutotaskAPIAuth $Projects = Get-AutotaskAPIResource -Resource Projects -SimpleSearch 'status ne completed' foreach ($Project in $Projects) { $NewTeam = New-Team -MailNickname "$($project.projectnumber)" -DisplayName "$($project.projectnumber) - $($project.name)" -Visibility "private" $TeamLeadEmail = (Get-AutotaskAPIResource -Resource resources -ID $($project.projectLeadResourceID)).email Add-TeamUser -GroupId $NewTeam.GroupId -User $TeamLeadEmail } ``` -------------------------------- ### Authenticate with AutotaskAPI Source: https://github.com/kelvintegelaar/autotaskapi/blob/master/README.md Adds authentication headers to AutotaskAPI requests. Requires an API Integration Code and credentials. It attempts to determine the correct webservice URL based on the provided credentials. ```powershell $Creds = Get-Credential Add-AutotaskAPIAuth -ApiIntegrationCode 'ABCDEFGH00100244MMEEE333' -credentials $Creds ``` -------------------------------- ### Set AutotaskAPI Base URI Source: https://github.com/kelvintegelaar/autotaskapi/blob/master/README.md Manually sets the Autotask REST API webservice URL. This is necessary if the automatic detection of the webservice URL fails. The function supports tab completion for finding the correct URI. ```powershell Add-AutotaskBaseURI -BaseURI https://webservices1.autotask.net/atservicesrest ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.