Repository navigation
v1.4.0
Added
-
Resolved PRTG credential placeholders are masked in sensor messages, error text, and log
files. PRTG's manual warns that placeholders are resolved before the output is displayed,
so a credential echoed back in an error message - a failingInvoke-RestMethodthat includes
the full request URI, say - ends up on screen in the clear. The module now registers the
values it can know about and masks them on the way out:- the resolved
prtg_windowspassword,prtg_linuxpassword, andprtg_snmpcommunity
environment variables, when "Set placeholders as environment values" is enabled in the
sensor settings. These hold the same strings the command line received, so this also
covers a credential passed as a script parameter. User names, domains, and host names are
deliberately not masked: they are not secrets and hiding them only makes
troubleshooting harder. Neither are the RFC 1157 default SNMP communitiespublicand
private, which are not secrets and are far too common as ordinary words to mask; - every value returned by
Get-PrtgSecret -AsPlainText.
Masking is partial so an operator can still tell which credential leaked: values of 12
characters or more keep their first few characters (at most six), shorter values are masked
entirely, and the asterisk mask itself is always five characters, so the output never grows
with the secret. Values under six characters are never registered - masking those would
mangle ordinary text for no real protection.Nothing to configure and nothing to opt into. See the limitations in
Docs/secrets.md- notably that only exact substring matches are found
(a URL-encoded or base64'd form is not), and thatSet-PrtgOutput,Write-PrtgOutput,
channel names/values, andInvoke-PrtgSensor -DryRunare not covered. - the resolved
Security
- The masking above is defence in depth, not a guarantee. It reduces the blast radius of an
accidental credential leak into sensor output; it does not make credentials safe to log. Keep
treating credentials as sensitive and keep them out of messages you build yourself.
Changed
-
Add-PrtgChannelnow rejects a duplicate channel name. PRTG's manual requires the
<Channel>name to be "unique for the sensor"; the module enforced the 50-channel cap but
not uniqueness. Adding a name that was already added now throws, and the comparison is
case-insensitive (CPUandcpuin one sensor is a bug in every realistic case).This can turn previously green sensors red. Duplicates are easy to generate accidentally
from process, service, or disk names - an ordinary machine has 80+ process names with more
than one instance. Aggregate first, and cap the result: the same machine has well over 50
distinct process names, which would hit the 50-channel limit instead.Get-Process | Group-Object ProcessName | Sort-Object { ($_.Group | Measure-Object CPU -Sum).Sum } -Descending | Select-Object -First 10 | ForEach-Object { New-PrtgChannel -Channel $_.Name -Value ($_.Group | Measure-Object CPU -Sum).Sum -Unit CPU -Float } | Add-PrtgChannel
The
Add-PrtgChannelhelp example andDocs/channels.mddemonstrated the
broken pattern and have been rewritten to the aggregated, capped form above.
Fixed
-
Log retention no longer deletes files this module did not create. The
-MaxLogssweep in
Write-PrtgLogmatched every*.logfile in the log directory, so it deleted whatever it
found beyond the retention count. With the default-MaxLogs 30and an
Invoke-PrtgSensor -EnableLogging -LogPathpointed at a folder holding 40 unrelated
application logs, 11 of them were destroyed on the first run - and two sensor scripts sharing
one-LogPath(the layout the help recommends,-LogPath "$PSScriptRoot\Logs") silently
pruned each other's history. The sweep now only considers files matching this script's own
run-file shape,<scriptname>_<yyyyMMdd-HHmmss>_<pid>.log.Note that retention is therefore per script name: run files left behind by a sensor script
that has since been renamed are no longer pruned automatically. Never deleting a file we did
not create is worth that. -
A relative
-Pathno longer sends the state lock to a different folder than the state
file. The.locksidecar is handed straight to[System.IO.FileStream], and .NET resolves
a relative path against the process working directory, which is not PowerShell's current
location.Save-PrtgSensorState -Key k -Value 42 -Path 'store'therefore either stalled for
the full-TimeoutSecondsand then blamed a concurrent sensor run that did not exist, or -
when astorefolder happened to exist under both - wrote the state file and its lock into
two different directories, so concurrent runs serialized on different locks while writing the
same file. PRTG starts sensors with an unhelpful working directory, so this was reachable in
production. The path is now normalised once in the shared resolver, so the folder, the state
file, and the lock can never disagree. -
A state lock in a folder that does not exist now fails immediately with a message naming
the missing folder, instead of retrying until the timeout and reporting a lock conflict.
DirectoryNotFoundExceptionderives fromIOExceptionand was landing in the retry arm. -
Internal: every parameter and local in the private
Invoke-PrtgStateLockis now prefixed
PrtgLock. A script block passed to it resolves unqualified variable names up the dynamic
chain - the lock's own frame first - so its former parameter names (LockFile,
ScriptBlock,TimeoutSeconds,Force,DeleteLockOnRelease) were an undocumented reserved
list that would silently shadow a caller's variable of the same name. This had already bitten
once insideUse-PrtgCachedResult, whose workaround is now removed.