Skip to content

v1.3.0

Choose a tag to compare

@github-actions github-actions released this 27 Jul 20:19
· 64 commits to master since this release
30cd57f

Added

  • Use-PrtgCachedResult -SkipNullCache: treats a $null result as nothing worth caching, so a
    stored $null is ignored on read and a $null returned by the block is not written. Off by
    default: a source that keeps returning $null is then refetched by every sensor on every
    interval instead of once. Use it when a $null means 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 on Save-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.
    -MinimumPercent fails 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 with TESTVM_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), and working/24 (raw CIM UInt64 values,
    including one above 2^53).

Changed

  • Invoke-PrtgSensor now 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 -ErrorAction on that statement,
    or assign $ErrorActionPreference INSIDE the block; see
    Examples/16-making-errors-nonterminating.ps1.
    Note that setting $ErrorActionPreference at the top of the sensor SCRIPT does not opt out; it
    has to be inside the block, or per command via -ErrorAction.

  • Save-PrtgSecret no 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.ps1 now fails on warnings, not only on errors, matching the compatibility check.

  • Tools/build.ps1 and Tools/install_dev_requirements.ps1 include the underlying error when
    they fail, instead of only reporting that the step failed.

  • Docs updated for the above: Docs/resilience.md gains a section on terminating errors inside
    the block, Docs/secrets.md covers multiple sensor accounts and the upgrade step, and
    Docs/state.md / Docs/shared-cache.md spell out that -Latest maps a stored $null to
    -Default while the cache serves one as-is.

Fixed

  • New-PrtgChannel -Value accepted only int, int64, float, double, and decimal, and
    rejected every unsigned and small integer type. UInt64 is 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 -Value and on the four Limit*
    parameters (which continue to accept strings).
    Integers keep their exact value in the JSON, so a UInt64 above 2^53 is not rounded.
  • New-PrtgChannel emitted explicitly bound COMMON parameters as channel properties, so
    -Verbose or -ErrorAction SilentlyContinue added "Verbose":1 / "ErrorAction":"..." to the
    sensor JSON. Adding -Verbose while debugging silently changed the emitted payload. Common
    parameters are now excluded automatically, including -ProgressAction and anything future
    hosts add.
  • Invoke-PrtgSensor -EnableLogging -LogPath left the process's log run file pointed at the
    -LogPath folder after returning. Every later Write-PrtgLog call 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
    -LogPath actually redirected it - so a plain -EnableLogging call keeps the run file it
    created and later Write-PrtgLog calls still append to it.
  • Get-PrtgSensorState -Latest returned a stored $null instead of falling back to -Default,
    so $current - (Get-PrtgSensorState -Key 'k' -Latest -Default 0) silently yielded $current.
    A stored 0, '', or $false still comes back unchanged. Use-PrtgCachedResult deliberately
    keeps the opposite behaviour: a cached $null is a valid result and is served from the cache.
  • Save-PrtgSecret could 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-Clixml truncates the file
    before it writes, so the previous value was already gone by the time the write threw, leaving a
    truncated file that a later Get-PrtgSecret reported 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-PrtgSensorState and Clear-PrtgSensorState -MaxAge wrote 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 -Default for one interval. Both now write to a temp file and
    swap it in, so a failed write leaves the previous history intact.
  • Save-PrtgSecret reported a name already owned by another account as a raw
    Access to the path ... is denied naming its internal temp file. The error now names the
    secret, the target file, and the account the save is running as.
  • Save-PrtgSecret left 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-PrtgCachedResult refreshed 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
    way Save-PrtgSecret does.
  • Get-PrtgSecret returned $null for an empty or truncated secret file, because such a file
    deserializes to $null without raising an error. It now throws and names the file. With
    -AsPlainText this previously surfaced as You cannot call a method on a null-valued expression.
  • Get-PrtgSecret reported 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 -AsPlainText silently returned the raw object when the stored payload was
    neither a PSCredential nor a SecureString (only reachable via a hand-written clixml or a
    -Path aimed 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-PrtgOutput and Write-PrtgError set [Console]::OutputEncoding without a guard. Under
    .NET Framework that setter can throw when the process has no attached console, and it runs
    BEFORE the response is written - so Write-PrtgError would have emitted nothing at the exact
    moment it mattered. Both are now guarded so the response is always emitted.