change verbs and fixed function Set-edgesearchengine

This commit is contained in:
2025-11-28 20:41:02 -05:00
parent 2781493231
commit 6ace48d9c4

149
samy.ps1
View File

@@ -1,4 +1,4 @@
#region changes to be done
#region changes to be done
#endregion changes to be done
@@ -787,13 +787,13 @@ if (-not [System.Diagnostics.EventLog]::SourceExists('$EventSource')) {
$Global:SamyTasks = @(
# On-Boarding, left column
@{ Id='setSVSPowerplan'; Name='setSVSPowerplan'; Label='Set SVS Powerplan'; HandlerFn='Handle-setSVSPowerPlan'; Page='onboard'; Column='left' },
@{ Id='installSVSMSPModule'; Name='installSVSMSPModule'; Label='Install SVSMSP Module'; HandlerFn='Handle-InstallSVSMSP'; Page='onboard'; Column='left' },
@{ Id='installCyberQP'; Name='installCyberQP'; Label='Install CyberQP'; HandlerFn='Handle-InstallCyberQP'; Page='onboard'; Column='left' },
@{ Id='installSVSHelpDesk'; Name='installSVSHelpDesk'; Label='Install SVS HelpDesk'; HandlerFn='Handle-InstallSVSHelpDesk'; Page='onboard'; Column='left' },
@{ Id='installThreatLocker'; Name='installThreatLocker'; Label='Install ThreatLocker'; HandlerFn='Handle-InstallThreatLocker'; Page='onboard'; Column='left' },
@{ Id='installRocketCyber'; Name='installRocketCyber'; Label='Install RocketCyber'; HandlerFn='Handle-InstallRocketCyber'; Page='onboard'; Column='left' },
@{ Id='installDattoRMM'; Name='installDattoRMM'; Label='Install DattoRMM'; HandlerFn='Handle-InstallDattoRMM'; Page='onboard'; Column='left';
@{ Id='setSVSPowerplan'; Name='setSVSPowerplan'; Label='Set SVS Powerplan'; HandlerFn='Invoke-setSVSPowerPlan'; Page='onboard'; Column='left' },
@{ Id='installSVSMSPModule'; Name='installSVSMSPModule'; Label='Install SVSMSP Module'; HandlerFn='Invoke-InstallSVSMSP'; Page='onboard'; Column='left' },
@{ Id='installCyberQP'; Name='installCyberQP'; Label='Install CyberQP'; HandlerFn='Invoke-InstallCyberQP'; Page='onboard'; Column='left' },
@{ Id='installSVSHelpDesk'; Name='installSVSHelpDesk'; Label='Install SVS HelpDesk'; HandlerFn='Invoke-InstallSVSHelpDesk'; Page='onboard'; Column='left' },
@{ Id='installThreatLocker'; Name='installThreatLocker'; Label='Install ThreatLocker'; HandlerFn='Invoke-InstallThreatLocker'; Page='onboard'; Column='left' },
@{ Id='installRocketCyber'; Name='installRocketCyber'; Label='Install RocketCyber'; HandlerFn='Invoke-InstallRocketCyber'; Page='onboard'; Column='left' },
@{ Id='installDattoRMM'; Name='installDattoRMM'; Label='Install DattoRMM'; HandlerFn='Invoke-InstallDattoRMM'; Page='onboard'; Column='left';
SubOptions= @(
@{ Value='inputVar'; Label='Copy Site Variables' },
@{ Value='rmm'; Label='Install RMM Agent' },
@@ -804,22 +804,22 @@ if (-not [System.Diagnostics.EventLog]::SourceExists('$EventSource')) {
# On-Boarding, right column (optional bits)
@{ Id='enableBitLocker'; Name='EnableBitLocker'; Label='Enable BitLocker'; HandlerFn='Set-SVSBitLocker'; Page='onboard'; Column='right' },
@{ Id='setEdgeDefaultSearch';Name='setedgedefaultsearch';Label='Set Edge Default Search'; Tooltip='Will configure Edge to use Google as default search provider'; HandlerFn='set-EdgeDefaultSearchProvider';Page='onboard'; Column='right' },
@{ Id='setEdgeDefaultSearch';Name='setedgedefaultsearch';Label='Set Edge Default Search'; Tooltip='Will configure Edge to use Google as default search provider'; HandlerFn='Invoke-SetEdgeDefaultSearchEngine';Page='onboard'; Column='right' },
# Off-Boarding
@{ Id='offUninstallCyberQP'; Name='offUninstallCyberQP'; Label='Uninstall CyberQP'; HandlerFn='Handle-UninstallCyberQP'; Page='offboard' },
@{ Id='offUninstallSVSHelpDesk'; Name='offUninstallSVSHelpDesk'; Label='Uninstall SVS HelpDesk'; HandlerFn='Handle-UninstallSVSHelpDesk'; Page='offboard' },
@{ Id='offUninstallThreatLocker'; Name='offUninstallThreatLocker'; Label='Uninstall ThreatLocker'; HandlerFn='Handle-UninstallThreatLocker'; Page='offboard' },
@{ Id='offUninstallRocketCyber'; Name='offUninstallRocketCyber'; Label='Uninstall RocketCyber'; HandlerFn='Handle-UninstallRocketCyber'; Page='offboard' },
@{ Id='offCleanupSVSMSPModule'; Name='offCleanupSVSMSPModule'; Label='Cleanup SVSMSP Toolkit'; HandlerFn='Handle-CleanupSVSMSP'; Page='offboard' },
@{ Id='offUninstallCyberQP'; Name='offUninstallCyberQP'; Label='Uninstall CyberQP'; HandlerFn='Invoke-UninstallCyberQP'; Page='offboard' },
@{ Id='offUninstallSVSHelpDesk'; Name='offUninstallSVSHelpDesk'; Label='Uninstall SVS HelpDesk'; HandlerFn='Invoke-UninstallSVSHelpDesk'; Page='offboard' },
@{ Id='offUninstallThreatLocker'; Name='offUninstallThreatLocker'; Label='Uninstall ThreatLocker'; HandlerFn='Invoke-UninstallThreatLocker'; Page='offboard' },
@{ Id='offUninstallRocketCyber'; Name='offUninstallRocketCyber'; Label='Uninstall RocketCyber'; HandlerFn='Invoke-UninstallRocketCyber'; Page='offboard' },
@{ Id='offCleanupSVSMSPModule'; Name='offCleanupSVSMSPModule'; Label='Cleanup SVSMSP Toolkit'; HandlerFn='Invoke-CleanupSVSMSP'; Page='offboard' },
# Tweaks
@{ Id='disableAnimations'; Name='disableAnimations'; Label='Disable Animations'; HandlerFn='Disable-Animations'; Page='tweaks' },
# SVS Apps
@{ Id='wingetLastpass'; Name='wingetLastpass'; Label='LastPass Desktop App'; HandlerFn='Install-WingetLastPass'; Page='SVSApps' },
@{ Id='wingetChrome'; Name='wingetChrome'; Label='Google Chrome'; HandlerFn='Handle-InstallChrome'; Page='SVSApps' },
@{ Id='wingetAcrobat'; Name='wingetAcrobat'; Label='Adobe Acrobat Reader (64-bit)'; HandlerFn='Handle-InstallAcrobat'; Page='SVSApps' }
@{ Id='wingetChrome'; Name='wingetChrome'; Label='Google Chrome'; HandlerFn='Invoke-InstallChrome'; Page='SVSApps' },
@{ Id='wingetAcrobat'; Name='wingetAcrobat'; Label='Adobe Acrobat Reader (64-bit)'; HandlerFn='Invoke-InstallAcrobat'; Page='SVSApps' }
)
Write-LogHybrid "Tasks by page: onboard=$(
@@ -1167,7 +1167,7 @@ $jsContent
#region Handler Stubs
#region HTTP responder helpers
function Respond-Text {
function Send-Text {
param($Context, $Text)
if (-not $Context -or -not $Context.Response) {
return
@@ -1179,7 +1179,7 @@ $jsContent
$Context.Response.OutputStream.Close()
}
function Respond-HTML {
function Send-HTML {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)][object] $Context,
@@ -1195,7 +1195,7 @@ $jsContent
$Context.Response.OutputStream.Close()
}
function Respond-JSON {
function Send-JSON {
param($Context, $Object)
if (-not $Context -or -not $Context.Response) {
return
@@ -1210,7 +1210,7 @@ function Respond-JSON {
#endregion HTTP responder helpers
#region Datto handlers
function Handle-FetchSites {
function Invoke-FetchSites {
param($Context)
try {
@@ -1230,13 +1230,13 @@ function Respond-JSON {
-OutputFile $OutputFile
# 3) Return JSON array of sites
Respond-JSON $Context $sites
Send-JSON $Context $sites
}
catch {
# Log the exception and return HTTP 500
Write-LogHybrid "Handle-FetchSites error: $($_.Exception.Message)" Error DattoRMM -LogToEvent
Write-LogHybrid "Invoke-FetchSites error: $($_.Exception.Message)" Error DattoRMM -LogToEvent
$Context.Response.StatusCode = 500
Respond-Text $Context "Internal server error fetching sites."
Send-Text $Context "Internal server error fetching sites."
}
}
@@ -1244,7 +1244,7 @@ function Respond-JSON {
#region Onboarding handlers
# On-boarding handlers
function Handle-SetSVSPowerPlan {
function Invoke-SetSVSPowerPlan {
param($Context)
# 1) call into your module
@@ -1252,22 +1252,22 @@ function Respond-JSON {
# 2) log & write back a simple text response
Write-LogHybrid "PowerPlan set" "Success" "OnBoard"
Respond-Text $Context "PowerPlan applied"
Send-Text $Context "PowerPlan applied"
}
function Handle-InstallSVSMSP {
function Invoke-InstallSVSMSP {
param($Context)
Write-LogHybrid "HTTP trigger: Handle-InstallSVSMSP" "Info" "OnBoard"
Write-LogHybrid "HTTP trigger: Invoke-InstallSVSMSP" "Info" "OnBoard"
try {
Install-SVSMSP -InstallToolkit
Respond-Text $Context "SVSMSP Module installed/updated."
Send-Text $Context "SVSMSP Module installed/updated."
} catch {
Write-LogHybrid "Error in Install-SVSMSP: $_" "Error" "OnBoard"
Respond-Text $Context "ERROR: $_"
Send-Text $Context "ERROR: $_"
}
}
function Handle-InstallCyberQP {
function Invoke-InstallCyberQP {
param($Context)
# 1) call into your module
@@ -1275,10 +1275,10 @@ function Respond-JSON {
# 2) log & write back a simple text response
Write-LogHybrid "CyberQP installed" "Success" "OnBoard"
Respond-Text $Context "CyberQP installed"
Send-Text $Context "CyberQP installed"
}
function Handle-InstallThreatLocker {
function Invoke-InstallThreatLocker {
param($Context)
# 1) call into your module
@@ -1286,10 +1286,10 @@ function Respond-JSON {
# 2) log & write back a simple text response
Write-LogHybrid "ThreatLocker installed" "Success" "OnBoard"
Respond-Text $Context "ThreatLocker installed"
Send-Text $Context "ThreatLocker installed"
}
function Handle-InstallRocketCyber {
function Invoke-InstallRocketCyber {
param($Context)
# 1) call into your module
@@ -1297,10 +1297,10 @@ function Respond-JSON {
# 2) log & write back a simple text response
Write-LogHybrid "RocketCyber installed" "Success" "OnBoard"
Respond-Text $Context "RocketCyber installed"
Send-Text $Context "RocketCyber installed"
}
function Handle-InstallSVSHelpDesk {
function Invoke-InstallSVSHelpDesk {
param($Context)
# 1) call into your module
@@ -1308,19 +1308,33 @@ function Respond-JSON {
# 2) log & write back a simple text response
Write-LogHybrid "SVS HelpDesk installed" "Success" "OnBoard"
Respond-Text $Context "SVS HelpDesk installed"
Send-Text $Context "SVS HelpDesk installed"
}
function Invoke-SetEdgeDefaultSearchEngine {
param($Context)
try {
Write-LogHybrid "Configuring Edge default search provider" Info OnBoard
set-EdgeDefaultSearchEngine
Write-LogHybrid "Edge default search set to Google" Success OnBoard
Send-Text $Context "Edge default search provider configured."
} catch {
Write-LogHybrid "Failed to set Edge default search: $($_.Exception.Message)" Error OnBoard
Send-Text $Context "ERROR: $($_.Exception.Message)"
}
}
#endregion Onboarding handlers
function Handle-InstallDattoRMM {
function Invoke-InstallDattoRMM {
param($Context)
try {
if ($Context.Request.HttpMethod -ne 'POST') {
$Context.Response.StatusCode = 405
Respond-Text $Context 'Use POST'
Send-Text $Context 'Use POST'
return
}
@@ -1339,38 +1353,38 @@ function Respond-JSON {
-SaveCopy: ($data.checkedValues -contains 'exe')
# 3) Acknowledge to the client
Respond-Text $Context "Triggered DattoRMM for $($data.Name)"
Send-Text $Context "Triggered DattoRMM for $($data.Name)"
}
catch {
# Log the exception and return HTTP 500
Write-LogHybrid "Handle-InstallDattoRMM error: $($_.Exception.Message)" Error DattoRMM -LogToEvent
Write-LogHybrid "Invoke-InstallDattoRMM error: $($_.Exception.Message)" Error DattoRMM -LogToEvent
$Context.Response.StatusCode = 500
Respond-Text $Context "Internal server error during DattoRMM install."
Send-Text $Context "Internal server error during DattoRMM install."
}
}
#endregion Datto handlers
#region App handlers
function Handle-InstallChrome { param($Context)
function Invoke-InstallChrome { param($Context)
try {
winget install --id=Google.Chrome --silent --accept-package-agreements --accept-source-agreements
Write-LogHybrid "Installed Google Chrome via winget" Success SVSApps -LogToEvent
Respond-Text $Context "Chrome installed"
Send-Text $Context "Chrome installed"
} catch {
Write-LogHybrid "Chrome install failed: $($_.Exception.Message)" Error SVSApps -LogToEvent
Respond-Text $Context "ERROR: $($_.Exception.Message)"
Send-Text $Context "ERROR: $($_.Exception.Message)"
}
}
function Handle-InstallAcrobat { param($Context)
function Invoke-InstallAcrobat { param($Context)
try {
winget install --id=Adobe.Acrobat.Reader.64-bit --silent --accept-package-agreements --accept-source-agreements
Write-LogHybrid "Installed Adobe Acrobat Reader (64-bit) via winget" Success SVSApps -LogToEvent
Respond-Text $Context "Acrobat Reader installed"
Send-Text $Context "Acrobat Reader installed"
} catch {
Write-LogHybrid "Acrobat install failed: $($_.Exception.Message)" Error SVSApps -LogToEvent
Respond-Text $Context "ERROR: $($_.Exception.Message)"
Send-Text $Context "ERROR: $($_.Exception.Message)"
}
}
@@ -1378,79 +1392,79 @@ function Handle-InstallAcrobat { param($Context)
#region Offboarding handlers
function Handle-UninstallCyberQP {
function Invoke-UninstallCyberQP {
param($Context)
try {
if (Get-Command Uninstall-CyberQP -ErrorAction Stop) {
Uninstall-CyberQP
Write-LogHybrid "CyberQP uninstalled" Success OffBoard -LogToEvent
Respond-Text $Context "CyberQP uninstalled."
Send-Text $Context "CyberQP uninstalled."
} else {
throw "Uninstall-CyberQP cmdlet not found in SVSMSP toolkit."
}
}
catch {
Write-LogHybrid "Error uninstalling CyberQP: $($_.Exception.Message)" Error OffBoard -LogToEvent
Respond-Text $Context "ERROR: $($_.Exception.Message)"
Send-Text $Context "ERROR: $($_.Exception.Message)"
}
}
function Handle-UninstallSVSHelpDesk {
function Invoke-UninstallSVSHelpDesk {
param($Context)
try {
if (Get-Command Uninstall-SVSHelpDesk -ErrorAction Stop) {
Uninstall-SVSHelpDesk
Write-LogHybrid "SVS HelpDesk uninstalled" Success OffBoard -LogToEvent
Respond-Text $Context "SVS HelpDesk uninstalled."
Send-Text $Context "SVS HelpDesk uninstalled."
} else {
throw "Uninstall-SVSHelpDesk cmdlet not found in SVSMSP toolkit."
}
}
catch {
Write-LogHybrid "Error uninstalling SVS HelpDesk: $($_.Exception.Message)" Error OffBoard -LogToEvent
Respond-Text $Context "ERROR: $($_.Exception.Message)"
Send-Text $Context "ERROR: $($_.Exception.Message)"
}
}
function Handle-UninstallThreatLocker {
function Invoke-UninstallThreatLocker {
param($Context)
try {
if (Get-Command Uninstall-ThreatLocker -ErrorAction Stop) {
Uninstall-ThreatLocker
Write-LogHybrid "ThreatLocker uninstalled" Success OffBoard -LogToEvent
Respond-Text $Context "ThreatLocker uninstalled."
Send-Text $Context "ThreatLocker uninstalled."
} else {
throw "Uninstall-ThreatLocker cmdlet not found in SVSMSP toolkit."
}
}
catch {
Write-LogHybrid "Error uninstalling ThreatLocker: $($_.Exception.Message)" Error OffBoard -LogToEvent
Respond-Text $Context "ERROR: $($_.Exception.Message)"
Send-Text $Context "ERROR: $($_.Exception.Message)"
}
}
function Handle-UninstallRocketCyber {
function Invoke-UninstallRocketCyber {
param($Context)
try {
if (Get-Command Uninstall-RocketCyber -ErrorAction Stop) {
Uninstall-RocketCyber
Write-LogHybrid "RocketCyber uninstalled" Success OffBoard -LogToEvent
Respond-Text $Context "RocketCyber uninstalled."
Send-Text $Context "RocketCyber uninstalled."
} else {
throw "Uninstall-RocketCyber cmdlet not found in SVSMSP toolkit."
}
}
catch {
Write-LogHybrid "Error uninstalling RocketCyber: $($_.Exception.Message)" Error OffBoard -LogToEvent
Respond-Text $Context "ERROR: $($_.Exception.Message)"
Send-Text $Context "ERROR: $($_.Exception.Message)"
}
}
function Handle-CleanupSVSMSP {
function Invoke-CleanupSVSMSP {
param($Context)
try {
@@ -1463,14 +1477,14 @@ function Handle-CleanupSVSMSP {
Install-SVSMSP -Cleanup
Write-LogHybrid "SVSMSP toolkit cleanup complete (module, repo, registry)." Success OffBoard -LogToEvent
Respond-Text $Context "SVSMSP toolkit cleanup complete."
Send-Text $Context "SVSMSP toolkit cleanup complete."
} else {
throw "Install-SVSMSP function not found in current session."
}
}
catch {
Write-LogHybrid "Error cleaning up SVSMSP toolkit: $($_.Exception.Message)" Error OffBoard -LogToEvent
Respond-Text $Context "ERROR: $($_.Exception.Message)"
Send-Text $Context "ERROR: $($_.Exception.Message)"
}
}
@@ -1713,7 +1727,7 @@ function Install-DattoRMM {
# ---- Shutdown handler ----
if ($path -eq 'quit') {
Write-LogHybrid "Shutdown requested" "Info" "Server" -LogToEvent
Respond-Text $Context "Server shutting down."
Send-Text $Context "Server shutting down."
# stop the listener loop
$Global:Listener.Stop()
return
@@ -1721,7 +1735,7 @@ function Install-DattoRMM {
# ---- Fetch Sites endpoint ----
if ($Context.Request.HttpMethod -eq 'POST' -and $path -eq 'getpw') {
Handle-FetchSites $Context
Invoke-FetchSites $Context
return
}
@@ -1729,7 +1743,7 @@ function Install-DattoRMM {
if ($path -in @('', 'onboard', 'offboard', 'tweaks', 'SVSApps')) {
$page = if ($path -eq '') { 'onboard' } else { $path }
$html = Get-UIHtml -Page $page
Respond-HTML $Context $html
Send-HTML $Context $html
return
}
@@ -1742,7 +1756,7 @@ function Install-DattoRMM {
# ---- 404 ----
$Context.Response.StatusCode = 404
Respond-Text $Context '404 - Not Found'
Send-Text $Context '404 - Not Found'
}
#endregion Dispatch-Request
@@ -1907,3 +1921,4 @@ function Install-DattoRMM {
}