Update samy.ps1
This commit is contained in:
169
samy.ps1
169
samy.ps1
@@ -1,172 +1,3 @@
|
|||||||
<#
|
|
||||||
Last changes made should fix the issues we had wen running thi in Windows 11 25H2
|
|
||||||
|
|
||||||
change this line for the message
|
|
||||||
<!-- Big red line under tagline -->
|
|
||||||
<div id="samyHint" class="samy-hint">Please use samy.svstools.ca</div>
|
|
||||||
|
|
||||||
Invoke-installprinters you can uncomment whatif in the function
|
|
||||||
|
|
||||||
# SAMY asset config (change branch or base once and it updates everything)
|
|
||||||
$Script:SamyBranch = 'beta' # or 'main'
|
|
||||||
line 268 - 281
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
Script Automation Monkey (SAMY) is a unified MSP assistant that automates onboarding, headless offboarding,
|
|
||||||
Datto RMM deployments, and toolkit management through a local UI, HTTP endpoints, or direct PowerShell switches.
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
Install-DattoRMM is the core helper that handles credential retrieval (webhook or direct), OAuth token management,
|
|
||||||
site list fetching/persistence, registry variable pushes, agent downloads/installs, and optional installer archiving.
|
|
||||||
The UI exposes all tasks as checkboxes with select-all helpers, and each action is wrapped in detailed logging plus
|
|
||||||
HTTP responders so callers can see success or failure.$jsContent = Get-RemoteText -Url $Script:SamyJsUrl
|
|
||||||
|
|
||||||
|
|
||||||
Key features:
|
|
||||||
- Credential retrieval - securely fetches ApiUrl, ApiKey, and ApiSecretKey from a webhook when requested.
|
|
||||||
- OAuth management - automatically acquires and refreshes bearer tokens over TLS to talk to Datto.
|
|
||||||
- Site list fetching - returns the list of RMM sites and validates OutputFile extensions (.csv/.json).
|
|
||||||
- Site list persistence - saves fetched site lists to the requester's desktop as CSV or JSON.
|
|
||||||
- Registry variable push - writes site-specific variables under HKLM:\Software\SVS\Deployment.
|
|
||||||
- Agent download & install - pulls the Datto RMM agent, launches it, and optionally saves a copy to C:\Temp.
|
|
||||||
- HTTP endpoints - /getpw and /installDattoRMM handle UI or API-triggered workflows with failure trapping.
|
|
||||||
- Idempotent & WhatIf support - uses ShouldProcess/SupportsShouldProcess to protect installs.
|
|
||||||
- Headless Offboard - runs every offboarding task serially just like "Select All" in the UI.
|
|
||||||
|
|
||||||
Throughout, secrets are never written to logs or console, and all operations produce clear success/failure messages via Write-LogHybrid.
|
|
||||||
|
|
||||||
|
|
||||||
.PARAMETER UseWebhook
|
|
||||||
Switch that forces credential retrieval from the webhook at WebhookUrl using WebhookPassword.
|
|
||||||
When omitted, you must supply ApiUrl, ApiKey, and ApiSecretKey directly.
|
|
||||||
|
|
||||||
.PARAMETER WebhookPassword
|
|
||||||
Password to authenticate to the credentials-fetch webhook. Mandatory when -UseWebhook is set.
|
|
||||||
|
|
||||||
.PARAMETER WebhookUrl
|
|
||||||
URL of the credentials webhook endpoint. Defaults to $Global:DattoWebhookUrl.
|
|
||||||
|
|
||||||
.PARAMETER ApiUrl
|
|
||||||
Direct Datto RMM API base URL (used if not fetching from webhook).
|
|
||||||
|
|
||||||
.PARAMETER ApiKey
|
|
||||||
Direct Datto RMM API key (used if not fetching from webhook).
|
|
||||||
|
|
||||||
.PARAMETER ApiSecretKey
|
|
||||||
Direct Datto RMM secret (used if not fetching from webhook).
|
|
||||||
|
|
||||||
.PARAMETER FetchSites
|
|
||||||
Switch to fetch the list of RMM sites and skip all install or variable-push actions.
|
|
||||||
|
|
||||||
.PARAMETER SaveSitesList
|
|
||||||
Switch to save the fetched site list to the desktop as a file named by OutputFile.
|
|
||||||
Must be used together with -FetchSites.
|
|
||||||
|
|
||||||
.PARAMETER OutputFile
|
|
||||||
Name of the file to write the site list to (must end in “.csv” or “.json”).
|
|
||||||
Defaults to 'datto_sites.csv'.
|
|
||||||
|
|
||||||
.PARAMETER PushSiteVars
|
|
||||||
Switch to fetch site-specific variables and write them under HKLM:\Software\SVS\Deployment.
|
|
||||||
|
|
||||||
.PARAMETER InstallRMM
|
|
||||||
Switch to download and launch the Datto RMM agent installer for the specified site.
|
|
||||||
|
|
||||||
.PARAMETER SaveCopy
|
|
||||||
Switch to save a copy of the downloaded Datto RMM installer into C:\Temp.
|
|
||||||
|
|
||||||
.PARAMETER Offboard
|
|
||||||
Switch that runs every off-boarding task sequentially (same behavior as checking "Select All" on the Off-Boarding tab) without launching the web UI.
|
|
||||||
|
|
||||||
.PARAMETER SiteUID
|
|
||||||
The unique identifier of the Datto RMM site. Mandatory when performing install or variable-push.
|
|
||||||
|
|
||||||
.PARAMETER SiteName
|
|
||||||
The friendly name of the Datto RMM site (used in logging). Mandatory when performing install or variable-push.
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
Default EventLog : SVSMSP Events
|
|
||||||
Default Source : SAMY
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
|
|
||||||
& ([ScriptBlock]::Create( (iwr 'https://samy.svstools.com' -UseBasicParsing).Content )) `
|
|
||||||
-UseWebhook
|
|
||||||
-WebhookPassword 'pwd'
|
|
||||||
-SiteUID 'site-123'
|
|
||||||
-SiteName 'Acme Corp'
|
|
||||||
-PushSiteVars
|
|
||||||
-InstallRMM
|
|
||||||
|
|
||||||
# Headlessly installs the Datto RMM agent on “Acme Corp” and writes site variables to the registry.
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
& ([ScriptBlock]::Create( (iwr 'https://samy.svstools.com' -UseBasicParsing).Content )) `
|
|
||||||
-ApiUrl 'https://api.example.com' `
|
|
||||||
-ApiKey 'YourApiKey' `
|
|
||||||
-ApiSecretKey 'YourSecretKey' `
|
|
||||||
-SiteUID 'site-123' `
|
|
||||||
-SiteName 'Acme Corp' `
|
|
||||||
-PushSiteVars `
|
|
||||||
-InstallRMM
|
|
||||||
|
|
||||||
# Headlessly installs the Datto RMM agent on “Acme Corp” and writes site variables to the registry.
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
& ([ScriptBlock]::Create( (iwr 'https://samy.svstools.com' -UseBasicParsing).Content )) `
|
|
||||||
-UseWebhook `
|
|
||||||
-WebhookPassword 'pwd' `
|
|
||||||
-FetchSites `
|
|
||||||
-SaveSitesList `
|
|
||||||
-OutputFile 'sites.json'
|
|
||||||
|
|
||||||
# Fetches the full site list via webhook and saves it as JSON to your Desktop.
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
& ([ScriptBlock]::Create( (iwr 'https://samy.svstools.com' -UseBasicParsing).Content )) `
|
|
||||||
-ApiUrl 'https://api.example.com' `
|
|
||||||
-ApiKey 'YourApiKey' `
|
|
||||||
-ApiSecretKey 'YourSecretKey' `
|
|
||||||
-SiteUID 'site-123' `
|
|
||||||
-SiteName 'Acme Corp' `
|
|
||||||
-SaveCopy
|
|
||||||
|
|
||||||
# Downloads the RMM installer for “Acme Corp” and saves a copy under C:\Temp without running it.
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
& ([ScriptBlock]::Create( (iwr 'https://samy.svstools.com' -UseBasicParsing).Content )) `
|
|
||||||
-ApiUrl 'https://api.example.com' `
|
|
||||||
-ApiKey 'YourApiKey' `
|
|
||||||
-ApiSecretKey 'YourSecretKey' `
|
|
||||||
-SiteUID 'site-123' `
|
|
||||||
-SiteName 'Acme Corp' `
|
|
||||||
-InstallRMM `
|
|
||||||
-WhatIf
|
|
||||||
|
|
||||||
# Shows what would happen when installing the RMM agent, without making any changes.
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
& ([ScriptBlock]::Create((iwr 'samy.svstools.ca').Content )) -SilentInstall
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
& ([ScriptBlock]::Create((iwr 'samy.svstools.com').Content)) -Cleanup
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
& ([ScriptBlock]::Create((iwr 'samy.svstools.ca').Content)) -Offboard
|
|
||||||
|
|
||||||
# Runs the off-boarding tasks in sequence without launching the UI.
|
|
||||||
|
|
||||||
.Notes
|
|
||||||
|
|
||||||
RMM can call this directly
|
|
||||||
|
|
||||||
$profiles = Get-SvsPrinterProfilesFromServer -Uri 'https://bananas.svstools.ca/getprinters' -Password $pw
|
|
||||||
Set-SvsPrinterLocalConfig -PrinterProfiles $profiles -SkipIfEmpty
|
|
||||||
|
|
||||||
|
|
||||||
#>
|
|
||||||
#region Safely bypass Restricted Execution Policy
|
|
||||||
# ─── Safely bypass Restricted Execution Policy ───
|
|
||||||
#region Safely bypass Restricted Execution Policy
|
#region Safely bypass Restricted Execution Policy
|
||||||
# Safely bypass Restricted Execution Policy
|
# Safely bypass Restricted Execution Policy
|
||||||
if ($ExecutionContext.SessionState.LanguageMode -ne 'FullLanguage' -or
|
if ($ExecutionContext.SessionState.LanguageMode -ne 'FullLanguage' -or
|
||||||
|
|||||||
Reference in New Issue
Block a user