Update TGBeta.ps1
This commit is contained in:
@@ -163,7 +163,7 @@ function Install-DattoRMM-Helper {
|
|||||||
|
|
||||||
# Ensure mandatory parameters are provided
|
# Ensure mandatory parameters are provided
|
||||||
if (-not $ApiUrl -or -not $ApiKey -or -not $ApiSecretKey) {
|
if (-not $ApiUrl -or -not $ApiKey -or -not $ApiSecretKey) {
|
||||||
Write-Log -Message "Missing required parameters. Please provide ApiUrl, ApiKey, and ApiSecretKey." -Level "Error" -LogToEvent
|
Write-LogHybrid -Message "Missing required parameters. Please provide ApiUrl, ApiKey, and ApiSecretKey." -Level "Error" -LogToEvent
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ function Install-DattoRMM-Helper {
|
|||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
|
|
||||||
# Step 1: Fetch OAuth token
|
# Step 1: Fetch OAuth token
|
||||||
Write-Log -Message "Fetching OAuth token..." -Level "Info"
|
Write-LogHybrid -Message "Fetching OAuth token..." -Level "Info"
|
||||||
try {
|
try {
|
||||||
$securePassword = ConvertTo-SecureString -String 'public' -AsPlainText -Force
|
$securePassword = ConvertTo-SecureString -String 'public' -AsPlainText -Force
|
||||||
$apiGenToken = Invoke-WebRequest -Credential (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ('public-client', $securePassword)) `
|
$apiGenToken = Invoke-WebRequest -Credential (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ('public-client', $securePassword)) `
|
||||||
@@ -181,9 +181,9 @@ function Install-DattoRMM-Helper {
|
|||||||
-Body ('grant_type=password&username={0}&password={1}' -f $ApiKey, $ApiSecretKey) `
|
-Body ('grant_type=password&username={0}&password={1}' -f $ApiKey, $ApiSecretKey) `
|
||||||
| ConvertFrom-Json
|
| ConvertFrom-Json
|
||||||
$requestToken = $apiGenToken.access_token
|
$requestToken = $apiGenToken.access_token
|
||||||
Write-Log -Message "OAuth token fetched successfully." -Level "Success" -LogToEvent
|
Write-LogHybrid -Message "OAuth token fetched successfully." -Level "Success" -LogToEvent
|
||||||
} catch {
|
} catch {
|
||||||
Write-Log -Message "Failed to fetch OAuth token. Details: $($_.Exception.Message)" -Level "Error" -LogToEvent
|
Write-LogHybrid -Message "Failed to fetch OAuth token. Details: $($_.Exception.Message)" -Level "Error" -LogToEvent
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user