Force canada

This commit is contained in:
Chris Payne
2025-07-08 21:07:56 -04:00
parent 8cb90b71db
commit 9109252f54
3 changed files with 19 additions and 8 deletions

View File

@@ -1,21 +1,30 @@
function Invoke-AutotaskProvision {
param (
[Parameter(Mandatory)][string]$CompanyName,
[Parameter(Mandatory)][string]$PhoneNumber,
[Parameter(Mandatory)]
[string]$CompanyName,
[Parameter(Mandatory)]
[string]$PhoneNumber,
[string]$Website,
[string]$Street,
[string]$City,
[string]$Province,
[string]$PostalCode,
[string]$Country,
[Parameter(Mandatory)][hashtable]$Credentials
[string]$Country, # Not used but accepted for compatibility
[Parameter(Mandatory)]
[hashtable]$Credentials
)
if (-not $Credentials["AutotaskURL"] -or -not $Credentials["AutotaskIntCode"] -or -not $Credentials["AutotaskUsername"] -or -not $Credentials["AutotaskSecret"]) {
if (-not $Credentials["AutotaskURL"] -or
-not $Credentials["AutotaskIntCode"] -or
-not $Credentials["AutotaskUsername"] -or
-not $Credentials["AutotaskSecret"]) {
throw "Missing Autotask credentials in hashtable."
}
$Url = "https://$($Credentials["AutotaskURL"])/atservicesrest/v1.0/companies"
$BaseUrl = "https://$($Credentials["AutotaskURL"])/atservicesrest/v1.0/companies"
$Headers = @{
"ApiIntegrationcode" = $Credentials["AutotaskIntCode"]
@@ -38,7 +47,7 @@ function Invoke-AutotaskProvision {
} | ConvertTo-Json -Depth 3
try {
$Response = Invoke-RestMethod -Uri $Url -Method Post -Headers $Headers -Body $Body
$Response = Invoke-RestMethod -Uri $BaseUrl -Method Post -Headers $Headers -Body $Body
return $Response.itemId, $Response.id, $Response.companyID, $Response.item.id | Where-Object { $_ } | Select-Object -First 1
} catch {
throw "[Autotask] Provisioning failed: $($_.Exception.Message)"