Repository navigation
v1.3.0
Added
Use-PrtgCachedResult -SkipNullCache: treats a$nullresult as nothing worth caching, so a
stored$nullis ignored on read and a$nullreturned by the block is not written. Off by
default: a source that keeps returning$nullis then refetched by every sensor on every
interval instead of once. Use it when a$nullmeans the fetch failed and a retry is worth
the extra calls.Use-PrtgCachedResult -Depth: serialization depth for the cached value, same meaning and
default (5) as onSave-PrtgSensorState. The refresh previously always wrote at depth 5 with
no way to raise it, so a cached CIM instance or FileInfo lost its nested properties../tasks.ps1 coverage: runs the suite with code coverage and lists every missed command.
-MinimumPercentfails the run below a threshold. Coverage is per host, so compare hosts
before calling a line untested.Tools/deploy_to_testvm.sh: deploys the working tree to a Windows test VM, runs the suite on
Windows PowerShell 5.1 (x64 and x86) and pwsh 7, installs the built module for both editions,
and deploys the integration sensors to a PRTG probe. For developing on macOS, Linux, or WSL;
remote paths are overridable withTESTVM_REPO/TESTVM_EXEXML.Tools/README.md: what each developer tool does and how to run it.- Integration sensors for the 1.3.0 changes:
working/20+failing/21(a secret saved by the
sensor's own account vs. by the wrong one),failing/22+working/23(a non-terminating error
failing the sensor, and the supported opt-outs), andworking/24(raw CIMUInt64values,
including one above 2^53).
Changed
-
Invoke-PrtgSensornow really applies$ErrorActionPreference = 'Stop'to your script
block. It always claimed to, but the setting did not actually reach your block. A
NON-terminating error inside the block was therefore written to stderr and discarded, and the
sensor reported GREEN with missing or stale channels. Such a sensor now correctly reports an
error.
This can turn previously green sensors red, where the old behavior was hiding a real
failure. To let a specific command keep failing quietly, use-ErrorActionon that statement,
or assign$ErrorActionPreferenceINSIDE the block; see
Examples/16-making-errors-nonterminating.ps1.
Note that setting$ErrorActionPreferenceat the top of the sensor SCRIPT does not opt out; it
has to be inside the block, or per command via-ErrorAction. -
Save-PrtgSecretno longer ACL-locks the secret store FOLDER, only the individual secret
files. The store folder is shared by every sensor account on a probe, but each save re-locked it
to whichever account ran the save - cutting all the other accounts off from their own secret
files, which were still perfectly intact.Does this need action on upgrade?
-
Sensors run as Local System only (the PRTG default): no. Local System and Administrators
always kept access, so your store keeps working untouched. -
Some other account also uses the store: yes, once. That account was already locked out
before 1.3.0, and 1.3.0 does not clear the old folder ACL for you. As an administrator:Remove-Item "$env:ProgramData\PrtgSensorKit\Secrets" -Recurse -Force # then re-save each secret, running as the sensor account that needs it
Secret files themselves are unchanged: each stays locked to the account that saved it, plus
Administrators and SYSTEM. They are now locked down before the secret is written into them, so a
file is never briefly readable under inherited permissions. -
-
Tools/lint.ps1now fails on warnings, not only on errors, matching the compatibility check. -
Tools/build.ps1andTools/install_dev_requirements.ps1include the underlying error when
they fail, instead of only reporting that the step failed. -
Docs updated for the above:
Docs/resilience.mdgains a section on terminating errors inside
the block,Docs/secrets.mdcovers multiple sensor accounts and the upgrade step, and
Docs/state.md/Docs/shared-cache.mdspell out that-Latestmaps a stored$nullto
-Defaultwhile the cache serves one as-is.
Fixed
New-PrtgChannel -Valueaccepted onlyint,int64,float,double, anddecimal, and
rejected every unsigned and small integer type.UInt64is what CIM and WMI return for nearly
every size and counter (Win32_LogicalDisk.FreeSpace,Get-Volume.SizeRemaining,
Win32_OperatingSystem.FreePhysicalMemory), so those values had to be cast before use. All
built-in numeric types are now accepted -byte,sbyte,int16,uint16,int32,uint32,
int64,uint64,single,double,decimal- on-Valueand on the fourLimit*
parameters (which continue to accept strings).
Integers keep their exact value in the JSON, so aUInt64above 2^53 is not rounded.New-PrtgChannelemitted explicitly bound COMMON parameters as channel properties, so
-Verboseor-ErrorAction SilentlyContinueadded"Verbose":1/"ErrorAction":"..."to the
sensor JSON. Adding-Verbosewhile debugging silently changed the emitted payload. Common
parameters are now excluded automatically, including-ProgressActionand anything future
hosts add.Invoke-PrtgSensor -EnableLogging -LogPathleft the process's log run file pointed at the
-LogPathfolder after returning. Every laterWrite-PrtgLogcall in the same script went to
that folder instead of the script's own log directory, splitting one run across two folders.
The run file is now restored along with the directory and retention settings, and only when
-LogPathactually redirected it - so a plain-EnableLoggingcall keeps the run file it
created and laterWrite-PrtgLogcalls still append to it.Get-PrtgSensorState -Latestreturned a stored$nullinstead of falling back to-Default,
so$current - (Get-PrtgSensorState -Key 'k' -Latest -Default 0)silently yielded$current.
A stored0,'', or$falsestill comes back unchanged.Use-PrtgCachedResultdeliberately
keeps the opposite behaviour: a cached$nullis a valid result and is served from the cache.Save-PrtgSecretcould destroy an existing secret when a re-save failed part-way (for example
DPAPI being unavailable on a network logon, or a full disk).Export-Clixmltruncates the file
before it writes, so the previous value was already gone by the time the write threw, leaving a
truncated file that a laterGet-PrtgSecretreported as a confusing decrypt error. The secret
is now written to a temp file in the same folder and swapped in as a single step, so a failed
save leaves the previous secret intact and no partial file behind, on every platform.Save-PrtgSensorStateandClear-PrtgSensorState -MaxAgewrote the state file directly, so a
failure part-way through the write (full disk, a sensor killed on a PRTG timeout) emptied the
file and lost the ENTIRE entry history - the next run reported it as unreadable and a delta
counter silently fell back to-Defaultfor one interval. Both now write to a temp file and
swap it in, so a failed write leaves the previous history intact.Save-PrtgSecretreported a name already owned by another account as a raw
Access to the path ... is deniednaming its internal temp file. The error now names the
secret, the target file, and the account the save is running as.Save-PrtgSecretleft its temp file behind when the process was killed mid-save (a PRTG sensor
timeout, a reboot). Stale temp files for a given secret name are now cleared on the next save of
that name, and only when they are more than an hour old, so a second instance of the same sensor
saving at the same moment is never disturbed.Use-PrtgCachedResultrefreshed the cache with a direct write, so a failure part-way through
(full disk, killed process) corrupted the shared cache entry and sent every sensor using that
key back to the source at once. The refresh now writes a temp file and swaps it in, the same
waySave-PrtgSecretdoes.Get-PrtgSecretreturned$nullfor an empty or truncated secret file, because such a file
deserializes to$nullwithout raising an error. It now throws and names the file. With
-AsPlainTextthis previously surfaced asYou cannot call a method on a null-valued expression.Get-PrtgSecretreported a CORRUPT secret file (malformed XML from an interrupted write) as a
DPAPI account mismatch, sending operators to check permissions for a problem no re-permissioning
can fix. Malformed XML is now reported as file corruption; the account-mismatch wording is kept
for real decrypt failures.Get-PrtgSecret -AsPlainTextsilently returned the raw object when the stored payload was
neither aPSCredentialnor aSecureString(only reachable via a hand-written clixml or a
-Pathaimed at a foreign store). It now throws and names the actual type instead of returning
an object the caller asked to get as a string.Write-PrtgOutputandWrite-PrtgErrorset[Console]::OutputEncodingwithout a guard. Under
.NET Framework that setter can throw when the process has no attached console, and it runs
BEFORE the response is written - soWrite-PrtgErrorwould have emitted nothing at the exact
moment it mattered. Both are now guarded so the response is always emitted.