Windows file or folder over WinRM (win_file)
Checks that a file or a folder exists on a Windows machine and reads its size and the time of its last write. For a folder it counts the files in it, optionally only those whose name matches a filter such as *.bak, and reports the age of the newest. This is the "did the backup run" check. It reads CIM_DataFile and Win32_Directory over WinRM.
Transport. Under a Windows probe the device can be set to read this sensor over native WMI instead of WinRM; the queries and the result are the same. The target is then set up as in the WMI setup guide instead.
What it looks like

The sensor's page after a few polls, checking a folder of nightly *.bak backups on a Windows Server domain controller reached over WinRM. In the dark theme: the sensor's page. The form for adding it, with its parameters filled in: light, dark.
Channels
| Key | Name | Unit | Default limits |
|---|---|---|---|
exists | Exists | error below 1 (0 is Missing, 1 is Present) | |
age_s | Age (of the file, or of the newest file in a folder) | s | warning above 26 hours (93600), error above 48 hours (172800) |
size_bytes | Size (of the file, or of all counted files in a folder) | B | none |
file_count | Files (folders only) | error below 1 |
A missing file or folder is not a failed poll: it is a reading, exists is 0 and the age and size are unknown, so the default limit turns the sensor Down and the message says what was missing. The same holds for a folder with no file in it, or none that matches the filter: file_count is 0 and the age is unknown. That is the case of a backup that did not run.
The age is measured from the last write time (LastModified, not the creation time, which a copy resets) to the current time on the target, which the sensor reads in the same request (Win32_OperatingSystem.LocalDateTime). A machine whose clock is wrong therefore does not make its own files look old or new. Only if the target sends no time does the poll's own time stand in. A file written in the future is as new as can be (age 0).
The default limits suit a daily backup. For something else, change them on the sensor: a log that must be written every five minutes wants warn_max 600; a file that must not exist wants exists error_max 0 and the lower limit cleared; a folder that may be empty wants file_count cleared; a file you only want to find wants age_s cleared.
Parameters
| Parameter | Default | Meaning |
|---|---|---|
item | required | file or folder. |
path | required | The absolute path on a local drive: D:\Backups\nightly.bak, D:\Backups, C:\ for the root of a drive. Case does not matter, a / is read as \ and a trailing separator is ignored. |
filter | none | Folders only. Count only the files whose name matches: * is any run of characters and ? is one character, case ignored (*.bak, db-????.zip). It is matched against the file name, not the path. |
port | 5985, or 5986 with https | TCP port of the WinRM listener. |
https | false | Use the HTTPS listener instead of HTTP with message encryption. |
accept_self_signed | false | Accept an HTTPS certificate that cannot be verified. The credential has the same switch; either one is enough. |
Suggested interval: 300 seconds. Credential: Windows.
Which paths are accepted. A path must start with a drive letter and a separator. These are refused when the sensor is saved: UNC paths (\\server\share) and anything on a network share, relative paths, . and .. components, a doubled separator, * ? < > | " and : beyond the drive letter (which also rules out alternate data streams), % because environment variables are not expanded, control characters, names that end in a space or a dot (Windows would silently drop it), and paths over 260 characters. A quote (') is a legal character in a Windows name and is escaped inside the query. A mapped drive is not visible to the account WMI runs as; use the local path on the machine that holds the files.
A folder is read without its sub-folders. Only the files directly in it are counted; there is no recursive mode. Every query names the drive and the directory (WHERE Drive='D:' AND Path='\\Backups\\'), so WMI reads one directory and never walks a volume. A plain *.ext filter is also given to WMI as Extension='ext' (letters, digits and _ only), so a folder of many other files is not listed in full; every other filter is applied here, after the listing. A folder that holds 5000 or more files to look at fails the poll with a message asking for a narrower folder or a filter.
On the target
WinRM enabled and an account set up as in the WinRM setup guide. In addition the account must be allowed to read the folder in the file system (a read and list right on the folder). WMI does not say that it was refused: a file or folder the account cannot see is reported as missing, so give the account that right before trusting a "missing". Only local drives can be read, not network shares.
Failures
The WinRM failures every Windows sensor shares are listed in the setup guide. Specific to this sensor:
| Message | Meaning |
|---|---|
the path is not usable: ... (kind config) | A stored path that no longer passes the checks above. A new one is refused when it is saved. |
<folder> holds 5000 or more files to look at; narrow it with a filter ... (kind config) | Too many files to list. Use a filter such as *.bak, or a smaller folder. |
A missing file or folder is not a failure; see the channels above.
Testing
The recorded tests in crates/probeward-sensors/tests/sensors_win_process_file.rs replay answers from a real Windows Server 2022 machine. The live test in tests/winrm_live.rs reads a prepared folder on a Windows machine: PROBEWARD_TEST_WINRM_HOST, _USER and _PASSWORD as for the other Windows sensors, and PROBEWARD_TEST_WIN_FILE_DIR naming the folder (for example C:\Data). The test skips when it is not set. The folder holds a few files of its own, an empty sub-folder empty, and a sub-folder files with four files of 1000 bytes each: fresh.txt, and one-day.txt, one-week.bak and one-month.bak written 1, 7 and 30 days before it.