Update samy.ps1
This commit is contained in:
41
samy.ps1
41
samy.ps1
@@ -1689,6 +1689,47 @@ function Invoke-CleanupSVSMSP {
|
|||||||
|
|
||||||
#region Printer handlers
|
#region Printer handlers
|
||||||
|
|
||||||
|
function Get-SamyClientListFromServer {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Uri,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Password
|
||||||
|
)
|
||||||
|
|
||||||
|
try {
|
||||||
|
Write-LogHybrid "Calling client list service at $Uri" Info Printers -LogToEvent
|
||||||
|
|
||||||
|
# Adjust this to match how your bananas.svstools.ca endpoint expects auth.
|
||||||
|
# Here I'm assuming JSON POST { "password": "..." }.
|
||||||
|
$body = @{ password = $Password } | ConvertTo-Json
|
||||||
|
|
||||||
|
$resp = Invoke-RestMethod -Uri $Uri `
|
||||||
|
-Method Post `
|
||||||
|
-Body $body `
|
||||||
|
-ContentType 'application/json'
|
||||||
|
|
||||||
|
if (-not $resp) {
|
||||||
|
Write-LogHybrid "Client list service returned no data." Warning Printers -LogToEvent
|
||||||
|
return @()
|
||||||
|
}
|
||||||
|
|
||||||
|
# Normalize to an array
|
||||||
|
if ($resp -is [System.Collections.IEnumerable] -and -not ($resp -is [string])) {
|
||||||
|
return @($resp)
|
||||||
|
} else {
|
||||||
|
return ,$resp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-LogHybrid "Get-SamyClientListFromServer failed for $Uri: $($_.Exception.Message)" Error Printers -LogToEvent
|
||||||
|
return @()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function Invoke-GetPrinters {
|
function Invoke-GetPrinters {
|
||||||
param($Context)
|
param($Context)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user