Update StackMonkey.ps1
This commit is contained in:
@@ -133,7 +133,7 @@ $Global:DattoWebhookUrl = 'https://automate.svstools.ca/webhook/svsmspkit'
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 2) call the existing cmdlet from your module
|
# 2) call the existing cmdlet from your module
|
||||||
# (make sure you’ve already done Import-Module SVSMSP or the module that contains it)
|
# (make sure you've already done Import-Module SVSMSP or the module that contains it)
|
||||||
Install-DattoRMM `
|
Install-DattoRMM `
|
||||||
-ApiUrl $creds.ApiUrl `
|
-ApiUrl $creds.ApiUrl `
|
||||||
-ApiKey $creds.ApiKey `
|
-ApiKey $creds.ApiKey `
|
||||||
@@ -291,25 +291,6 @@ function Respond-JSON {
|
|||||||
$Context.Response.OutputStream.Close()
|
$Context.Response.OutputStream.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
|
||||||
#region Get-DattoApiCreds
|
|
||||||
function Get-DattoApiCredentials {
|
|
||||||
param ([string]$Password)
|
|
||||||
$headers = @{ "SVSMSPKit" = $Password }
|
|
||||||
try {
|
|
||||||
$response = Invoke-RestMethod -Uri $Global:DattoWebhookUrl -Headers $headers -Method GET
|
|
||||||
return @{
|
|
||||||
ApiUrl = $response.ApiUrl
|
|
||||||
ApiKey = $response.ApiKey
|
|
||||||
ApiSecretKey = $response.ApiSecretKey
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
Write-LogHybrid "Failed to fetch API credentials: $($_.Exception.Message)" "Error" "DattoAuth"
|
|
||||||
return $null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
#>
|
|
||||||
|
|
||||||
#region Install-DattoRMM-Helper
|
#region Install-DattoRMM-Helper
|
||||||
function Install-DattoRMM-Helper {
|
function Install-DattoRMM-Helper {
|
||||||
@@ -414,22 +395,7 @@ function Handle-FetchSites {
|
|||||||
param($Context)
|
param($Context)
|
||||||
|
|
||||||
# 1) Read incoming JSON (using block auto-disposes the reader)
|
# 1) Read incoming JSON (using block auto-disposes the reader)
|
||||||
|
|
||||||
|
|
||||||
<# powershell v7
|
|
||||||
using ($reader = [IO.StreamReader]::new($Context.Request.InputStream)) {
|
|
||||||
$raw = $reader.ReadToEnd()
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
$pw = (ConvertFrom-Json $raw).password
|
|
||||||
if (-not $pw) { throw "Missing `password` field" }
|
|
||||||
} catch {
|
|
||||||
Write-LogHybrid "Invalid JSON in /getpw payload: $($_.Exception.Message)" "Error" "FetchSites"
|
|
||||||
returnRespondEmpty $Context 400
|
|
||||||
return
|
|
||||||
}
|
|
||||||
#>
|
|
||||||
|
|
||||||
$reader = [IO.StreamReader]::new($Context.Request.InputStream)
|
$reader = [IO.StreamReader]::new($Context.Request.InputStream)
|
||||||
try {
|
try {
|
||||||
$raw = $reader.ReadToEnd()
|
$raw = $reader.ReadToEnd()
|
||||||
|
|||||||
Reference in New Issue
Block a user