From e4a9c3a5b7a82960dc6b174d5161c08f4563ab1c Mon Sep 17 00:00:00 2001 From: kenrward Date: Thu, 21 Nov 2024 20:40:10 -0500 Subject: [PATCH] Remove API Token Requirement --- .../install-CloudConnectorAPI.ps1 | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/Segment/Cloud Connector (Agent)/install-CloudConnectorAPI.ps1 b/Segment/Cloud Connector (Agent)/install-CloudConnectorAPI.ps1 index 295d441..ae6e991 100644 --- a/Segment/Cloud Connector (Agent)/install-CloudConnectorAPI.ps1 +++ b/Segment/Cloud Connector (Agent)/install-CloudConnectorAPI.ps1 @@ -1,10 +1,6 @@ -#update3.2 +#update 4.0 [CmdletBinding()] param( - # API Token to get download URL - [Parameter(Mandatory = $False)] - [String]$APIToken = " ", - # Install/Uninstall [Parameter(Mandatory = $True)] [ValidateSet("install", "uninstall")] @@ -20,6 +16,7 @@ param( [String]$CloudConnectorSource = "AD" ) + # Logging function $logFile = "$env:TEMP\CloudConnector.log" function Write-Log { @@ -32,19 +29,14 @@ function Write-Log { } Write-Log -Message "Script execution started." -# Validate API Token -if ($APIToken -eq "") { - Write-Log -Message "API Token is required but not provided." -Level "ERROR" +if ($CloudConnectorToken -eq "") { + Write-Log -Message "Cloud Connector Token is required for installation but not provided." -Level "ERROR" exit } # Define installer arguments switch ($CloudConnectorFunction) { "install" { - if ($CloudConnectorToken -eq "") { - Write-Log -Message "Cloud Connector Token is required for installation but not provided." -Level "ERROR" - exit - } $installerArgs = "-$CloudConnectorFunction -token $CloudConnectorToken -source $CloudConnectorSource" } "uninstall" { @@ -54,12 +46,12 @@ switch ($CloudConnectorFunction) { # Set up headers for API request $znHeaders = @{ - "Authorization" = $APIToken + "Authorization" = $CloudConnectorToken "Content-Type" = "application/json" } # API request for download URL -$installerUri = 'https://portal.zeronetworks.com/api/v1/download/cloud-connector/installer' +$installerUri = ' https://register-cloud-connector.zeronetworks.com/installer' $response = Invoke-WebRequest -Uri $installerUri -Method GET -Headers $znHeaders -ErrorAction Stop if ($response.StatusCode -ne 200) { Write-Log -Message "Failed to retrieve the download URL. HTTP Status Code: $($response.StatusCode)" -Level "ERROR" @@ -114,7 +106,7 @@ try { $setupLogPath = "$env:LOCALAPPDATA\ZeroNetworks\logs\setup.log" if (Test-Path -Path $setupLogPath) { $setupText = Get-Content $setupLogPath -Tail 1 - Write-Log -Message $setupText + Write-Log -Message "CloudConnector Log Output: $setupText" } # Clean up temporary files