From 9109252f54796feae953f3afd5a8fe8a3f2882c3 Mon Sep 17 00:00:00 2001 From: Chris Payne Date: Tue, 8 Jul 2025 21:07:56 -0400 Subject: [PATCH] Force canada --- layout.xaml | 2 +- main.ps1 | 2 ++ tools/autotask.ps1 | 23 ++++++++++++++++------- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/layout.xaml b/layout.xaml index 19248fa..7337c5c 100644 --- a/layout.xaml +++ b/layout.xaml @@ -127,7 +127,7 @@ - + diff --git a/main.ps1 b/main.ps1 index 960e93b..d6be1d6 100644 --- a/main.ps1 +++ b/main.ps1 @@ -105,6 +105,8 @@ $ITGlueBox.IsEnabled = $false $RocketcyberBox.IsEnabled = $false $CyberQPBox.IsEnabled = $false +$CountryBox.IsEnabled = $false + $AutotaskBox.Add_Checked({ $PhoneBox.Visibility = 'Visible' $WebsiteBox.Visibility = 'Visible' diff --git a/tools/autotask.ps1 b/tools/autotask.ps1 index 67996f6..fa5add8 100644 --- a/tools/autotask.ps1 +++ b/tools/autotask.ps1 @@ -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)"