9.6 KiB
Management Scripts
Most scripts here require the Tools.ps1 script. You can dot source that script like this:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
. $([Scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Tools.ps1')))
On older Windows PowerShell/.NET configurations, select TLS 1.2 before the first HTTPS download. The TLS setting inside Tools.ps1 cannot help download Tools.ps1 itself. See Microsoft's PowerShell TLS guidance.
You can then run any of the scripts using the Run-Script function: Run-Script -LivePSScript Script-Name
If you're using an RMM tool, the scripts in the /rmm directory are all that's needed to hook the main script in this directory.
For QuickBooks image-backup preparation, use Stop-QuickBooksDesktop.ps1
and Start-QuickBooksDesktop.ps1. The permanent
stop shim defines the host's exact company-file
share names as a semicolon-separated string and pairs with the
start shim. See deployment, exit codes, and
recovery before scheduling: desktop, database-service,
share-isolation, or open-handle failures prevent backup; post restores the
recorded services and share access. Each shim downloads its matching repository
script, Tools.ps1, and the shared QuickBooks routines live on every run. Only
the two shims need deployment; recovery state persists locally and no code is cached.
For DSA collection, paste rmm/Get-DSAManifest.ps1 into the RMM caller, preserving its configured platform variables. This caller selects TLS 1.2 before downloading, stops on bootstrap failure, and dot-sources the downloaded tools in the caller's scope. Updating the repository alone will not change an existing RMM caller.
For download failures, use the standalone Test-FileDownload.ps1 diagnostic. See the RMM caller, report guide, and shared caller audit. It compares the existing helper, BITS, and direct GET without changing production download behavior or running downloaded files.
Get-DSAManifest.ps1 uses Download-FileDirectly, which passes the original URL to BITS without preliminary Get-AbsoluteURI or IsURLValid requests. It accepts the same URL and optional -File arguments as Download-File, waits for completion, and throws on BITS errors. If -File is omitted, its temporary filename comes from the original URL; supply -File for extensionless URLs or URLs with query strings. Existing Download-File callers retain their previous behavior. Publish Tools.ps1 together with Get-DSAManifest.ps1 so the new helper is available.
Environment inventory
Use Get-EnvironmentInventory.ps1 to collect file shares, networks, printer connections, wireless observations, and internet egress into versioned JSON on Windows PowerShell 5.1. Reports describe the environment; endpoint identity is optional and no Hudu credentials or module are required. The RMM caller supports optional upload through the existing Filedrop helper. See the options and data contract and JSON schema. No importer is included.
Microsoft 365 deployment
See Office365-Deployment.md for the Syncro dropdowns and clean deployment workflow. Upload the shim in rmm/Install-MicrosoftOffice365.ps1; publish the core installer and resources/office/Office-UserCleanup.ps1 together first. The shim uses the existing Tools.ps1 unchanged; deployment, host relaunch, and result handling live in the main repository script. ValidateBeforeChanges defaults to true (checks and stages media only); explicitly select false to enable deployment. The workload runs in Windows PowerShell 5.1, requires an explicit subscription selection, removes Office and its companion apps, preserves Windows work-account sign-in, and installs the matching suite silently using Microsoft's current ODT. It then installs new Outlook and per-machine OneDrive using Microsoft's signed installers, plus current Teams only when the selected subscription includes Teams. Pending per-user cleanup is reported separately and protects the reinstalled apps. Action/error diagnostics use the existing Tools log; the result is printed to Syncro.
OneDrive folder preparation
Use Repair-OneDriveKnownFolderPaths.ps1 to preview and optionally shorten overlong filenames in a user's Documents, Pictures, and Desktop before OneDrive folder backup. It accounts for the projected OneDrive path, preserves extensions, avoids collisions, and saves a CSV plan and rename journal. Preview is the default; paths that require folder restructuring are reported. See the configuration and RMM guide and RMM caller.
Converting RMM boolean variables
After dot-sourcing Tools.ps1, use ConvertTo-RmmBoolean with any RMM variable:
$RestartEnabled = ConvertTo-RmmBoolean -Value $Restart -VariableName 'Restart'
If ( $RestartEnabled ) {
# Perform the requested restart.
}
# The variable name is optional; positional and pipeline input also work.
$ZipEnabled = ConvertTo-RmmBoolean $Zip
$UploadEnabled = $Upload | ConvertTo-RmmBoolean
Each input returns a System.Boolean: true, $true, yes, y, and 1 become $true; false, $false, no, n, 0, blank strings, and $null become $false. Case and surrounding whitespace are ignored, and native boolean values also work. Other values throw an error; -VariableName identifies the input in that error. The function returns the converted value without changing the original variable; assign the result wherever needed.
Get-DSAManifest.ps1 uses this helper for its three options. Publish it together with the updated Tools.ps1 so the helper is available to the RMM caller.
Converting RMM lists
Use ConvertTo-RmmList for an RMM string containing semicolon-separated values:
$Paths = @(ConvertTo-RmmList -Value 'C:\QB Data; \\server\Archive;')
$Shares = @(ConvertTo-RmmList -Value $QuickBooksShareNames)
The helper trims surrounding whitespace and omits empty entries. It preserves
item order, duplicates, case, internal spaces, commas, and backslashes. It does
not evaluate text, resolve paths, or check whether files/shares exist. Semicolons
are always separators; there is no quoting or escaping syntax. Use @(...) so
zero, one, and multiple items always produce an array. Publish the updated
Tools.ps1 with callers that use this new helper.
Uploading files
After dot-sourcing Tools.ps1, scripts can upload a completed file to the Emberkom FileDrop:
Upload-File -Path 'C:\ProgramData\Emberkom\Output\report.zip'
Get-DSAManifest.ps1 uploads its completed CSV or ZIP when $Upload is enabled. If $DeleteAfterUpload is also enabled, it deletes that same local file only after a confirmed successful upload. Disabled or failed uploads retain the file. $Zip, $Upload, and $DeleteAfterUpload all accept true, $true, yes, y, or 1; false, $false, no, n, 0, or an empty value disable the option. Casing and surrounding whitespace are ignored. The notification subject identifies the computer, and its message includes the source path and collection start time (local time with UTC offset).
The default destination is https://xfer.emberkom.com/filedrop/cmd. The sender defaults to the computer's hostname plus its primary DNS suffix, followed by @emberkom.com (for example, pc01.example.com@emberkom.com). Without a DNS suffix, it uses the hostname. Override these with -FileDropUrl and -From; -Subject and -Message are also optional.
Upload-File uses the LiquidFiles FileDrop API to obtain a temporary token, upload the file, and submit the message that triggers FileDrop delivery and its configured email notification. It returns a receipt with the path, destination, sender, attachment ID, byte count, and server status. It retains the local file and throws on failure.
Uploads use binary chunks with a default 10 MiB buffer, so large files do not need to fit in memory. The FileDrop's size and extension restrictions are checked before upload. -ChunkSizeMB, -RetryCount, and -TimeoutSeconds control chunk size, retries, and each request's timeout; -Verbose displays transfer details.
Allow the RMM job to run for the entire upload. The function waits for completion and retries failed chunks within that run; it does not resume across process restarts. LiquidFiles tokens expire after 24 hours. Final submission is attempted once: if its response is lost, check the FileDrop before rerunning to avoid duplicate notifications.
Offline tests (no uploads or notifications):
powershell.exe -NoProfile -File .\tests\Upload-File.Tests.ps1
powershell.exe -NoProfile -File .\tests\Get-DSAManifest.Tests.ps1
powershell.exe -NoProfile -File .\tests\Download-File.Tests.ps1
powershell.exe -NoProfile -File .\tests\ConvertTo-RmmBoolean.Tests.ps1
powershell.exe -NoProfile -File .\tests\ConvertTo-RmmList.Tests.ps1
powershell.exe -NoProfile -File .\tests\Get-AllNetworkDrives.Tests.ps1