Attempt to add more data for autotask

This commit is contained in:
Chris Payne
2025-07-08 21:06:00 -04:00
parent 9e21feb741
commit 8cb90b71db
2 changed files with 219 additions and 217 deletions

View File

@@ -1,21 +1,21 @@
function Invoke-AutotaskProvision {
param (
[Parameter(Mandatory)]
[string]$CompanyName,
[Parameter(Mandatory)]
[string]$PhoneNumber,
[Parameter(Mandatory)]
[hashtable]$Credentials
[Parameter(Mandatory)][string]$CompanyName,
[Parameter(Mandatory)][string]$PhoneNumber,
[string]$Website,
[string]$Street,
[string]$City,
[string]$Province,
[string]$PostalCode,
[string]$Country,
[Parameter(Mandatory)][hashtable]$Credentials
)
if (-not $Credentials["AutotaskURL"] -or -not $Credentials["AutotaskIntCode"] -or -not $Credentials["AutotaskUsername"] -or -not $Credentials["AutotaskSecret"]) {
throw "Missing Autotask credentials in hashtable."
}
$BaseURL = $Credentials["AutotaskURL"]
$Url = "https://$BaseURL/atservicesrest/v1.0/companies"
$Url = "https://$($Credentials["AutotaskURL"])/atservicesrest/v1.0/companies"
$Headers = @{
"ApiIntegrationcode" = $Credentials["AutotaskIntCode"]
@@ -28,12 +28,18 @@ function Invoke-AutotaskProvision {
companyName = $CompanyName
companyType = 1
phone = $PhoneNumber
website = $Website
address1 = $Street
city = $City
state = $Province
postalCode = $PostalCode
countryID = 38 # Statically set to Canada
ownerResourceID = 4
} | ConvertTo-Json -Depth 3
try {
$Response = Invoke-RestMethod -Uri $Url -Method Post -Headers $Headers -Body $Body
$Response.itemId, $Response.id, $Response.companyID, $Response.item.id | Where-Object { $_ } | Select-Object -First 1
return $Response.itemId, $Response.id, $Response.companyID, $Response.item.id | Where-Object { $_ } | Select-Object -First 1
} catch {
throw "[Autotask] Provisioning failed: $($_.Exception.Message)"
}