Skip to content

File Inventory

File Inventory lists files in folders you choose on Windows servers and clients. vScope connects to each target with remote PowerShell, walks the configured folders, and reports file names, paths, and sizes. It can also read the version information of executables and libraries. Use it to find out which machines have a specific application, DLL, or agent, and in which versions, including software that is not registered as installed.

File contents are never read. Only file metadata is collected and, when Read version is enabled, the version resource of each file.

Each file matching a folder row is reported with the following values:

ValueDescription
NameFile name, for example contoso.dll.
PathFull path of the file.
FolderFull path of the folder containing the file.
ExtensionFile extension in lowercase, without the dot.
SizeFile size in bytes.

With Read version enabled, executables and libraries also report their version resource:

ValueDescription
File VersionFile version as major.minor.build.revision, for example 4.2.0.1150.
Product VersionProduct version as written by the vendor.
Product NameProduct name, for example Contoso Agent.
Company NameCompany that produced the file.
DescriptionFile description.

Files without a version resource, such as text files, have empty version values.

The same file on several machines is one asset, linked to every machine it was found on. A file is identified by its path, file version, and size, regardless of the machine. Paths are compared case-insensitively.

  • Without Read version, files with the same path and size are one asset.
  • With Read version, each file version is a separate asset. A DLL at the same path in versions 4.1 and 4.2 gives two assets, each linked to the machines that have that version.

Enabling Read version for a folder that has already been inventoried therefore creates new assets for its files, since their identity now includes the version.

Files are shown in the Files table, with the file name as identifier and the path as secondary identifier. Open a file to see the machines it was found on.

Viewing the Files table and the File tags requires the Server or Client license module. Without one of them, files are still inventoried but not shown.


  • Remote PowerShell: PowerShell remoting must be enabled on the targets, and the vScope Server or Discovery Proxy must reach them on port 5985 (HTTP) or 5986 (HTTPS). See Windows (PowerShell).
  • PowerShell version: Windows PowerShell 5.0 or Windows Management Framework 5.1 must be installed on the targets.
  • Account: An account that can connect with remote PowerShell, read the configured folders, and read WMI (Win32_ComputerSystem) to identify the machine. A local administrator account meets all three. JEA, gMSA, and LAPS are supported in the same way as for Windows (PowerShell).

The machine is reported in the same way as by the Windows (PowerShell) data source, so files found by File Inventory are linked to the same machine asset as other Windows inventory.


  1. In vScope, go to Discovery > Credentials and select Create Credential.

  2. Select File Inventory (PowerShell).

  3. Select the Credential type used to connect to the targets:

    Credential typeConfiguration
    User & Password CredentialEnter the Windows account’s Username and Password, or use Reuse Credential to select an existing credential.
    No AuthenticationUse OS-managed authentication, for example a gMSA. See Using gMSA.
    LAPSLet vScope retrieve the target’s local administrator password from Active Directory. See Using LAPS.
  4. Under Inventory Settings > Folders, select Add folder and configure the folder as described in Folder settings. Add one row for each folder to inventory. At least one folder is required.

  5. Optional: change File Inventory Max Files, the maximum number of files reported per folder row. The default is 10,000.

  6. Under Advanced Settings, configure Use HTTPS, Skip Common Name Check, Port, and JEA Endpoint Name only if required by the targets’ remote PowerShell configuration. See Windows (PowerShell) advanced settings.

  7. Under Select targets, select the Windows machines to inventory.

  8. Click the lightning-bolt icon in a target’s Test column to test the credential. The test connects to the target and lists each folder as found or not found, without walking the folders.

  9. Save the credential and run discovery.


Each row under Folders describes one folder and which of its files to report.

FieldDescription
PathRequired. Full path of the folder, for example C:\Program Files\Contoso. Environment variables such as %ProgramFiles% and %SystemRoot% are expanded on each target.
SubfoldersLevels of subfolders to include: 0 for the folder only (default), 1 to 5 for that many levels, or * for any depth.
IncludeRegular expression matched against the file name. Only files whose names match are reported. All files are reported if empty.
ExcludeRegular expression matched against the file name. Files whose names match are not reported, even if they match Include.
Read versionRead the version resource of executables and libraries. Off by default. See How files become assets.

A folder that does not exist on a target is skipped for that target. This lets one credential cover machines where an application is installed in different places or not at all.

  • Include and Exclude use .NET regular expressions and are case-insensitive.
  • They are matched against the file name only, not the folder path.
  • They match anywhere in the name unless anchored. Use ^ and $ to match the whole name, and escape dots as \..
  • An expression that takes longer than one second on a file name is treated as not matching that file.
  • Invalid expressions are reported by the credential test and when discovery runs.
GoalPathSubfoldersIncludeExcludeRead version
Executables and libraries of an application, with versions%ProgramFiles%\Contoso*\.(exe|dll)$On
A specific file in a known folderC:\Program Files\Contoso\Agent0^agent\.exe$On
All configuration files except backupsC:\ProgramData\Contoso2\.(config|xml|json)$\.bak$Off
Every file in a folder, no subfoldersC:\Tools0Off
  • File Inventory Max Files limits the number of files reported per folder row, from 1 to 1,000,000. Files beyond the limit are not reported. Folders are walked level by level, so files closest to the configured folder are reported first.
  • A file matched by several folder rows is reported once.
  • Junctions and symbolic links to folders below the configured folder are not followed, since they may lead outside the folder or into a loop.
  • Folders the account cannot read are skipped.

File Inventory can connect through a JEA (Just Enough Administration) endpoint. JEA sessions cannot load scripts from vScope, so the File Inventory PowerShell module must be installed on each target and made available by the endpoint. Without JEA, vScope loads the same module in every session and nothing needs to be installed.

  1. Save the File Inventory module below as vScopeFileInventory.psm1.

  2. Install the module on each target by copying it to:

    C:\Program Files\WindowsPowerShell\Modules\vScopeFileInventory\vScopeFileInventory.psm1
  3. Add the module, its two functions, and the cmdlets used by vScope to the role capability file (.psrc) of the endpoint:

    Terminal window
    ModulesToImport = @('vScopeFileInventory')
    VisibleFunctions = @('Test-FileInventoryRules', 'Get-FileInventory')
    VisibleCmdlets = @('Get-Variable', 'Get-Command', 'Get-WmiObject', 'ConvertTo-Xml', 'ConvertTo-Json')

    The role capability for Windows (PowerShell) already allows these cmdlets. If you use that role, add the module to ModulesToImport and the two functions to VisibleFunctions.

  4. Enter the endpoint name in JEA Endpoint Name under Advanced Settings in the credential.

The module is the same one vScope loads in sessions without JEA. It reads file metadata and version resources only, and never changes anything on the target.

vScopeFileInventory.psm1
# vScope File Inventory module, used by FileInventoryProbe through the commands in file-inventory.yml.
#
# Without JEA, the probe loads this file as a dynamic module in every session before the custom config is processed.
# With JEA, the commands cannot be loaded by the probe, so this module must be installed on the target and made
# available by the JEA endpoint. In the role capability file:
#
# ModulesToImport = @('vScopeFileInventory')
# VisibleFunctions = @('Test-FileInventoryRules', 'Get-FileInventory')
# VisibleCmdlets = @('Get-Variable', 'Get-Command', 'Get-WmiObject', 'ConvertTo-Xml', 'ConvertTo-Json')
#
# The cmdlets are used by the probe itself, outside this module. Get-Variable reads $PSVersionTable and Get-Command
# lists the available commands when the session starts and in the credential test. Get-WmiObject, with the results
# converted by ConvertTo-Xml or ConvertTo-Json, reads Win32_ComputerSystem and its network adapters, BIOS and
# operating system, to report the computer the files are linked to as the same asset as the Windows probe. The role
# capability of the Windows (PowerShell) data source already allows them, so the module and the two functions can
# be added to that role instead of creating a new one.
#
# The module is installed by copying this file to
# $env:ProgramFiles\WindowsPowerShell\Modules\vScopeFileInventory\vScopeFileInventory.psm1
#
# Both exported functions take the rules of the credential as -Settings, base64 encoded UTF-8 JSON, so that the
# commands are plain command calls with a literal argument, as required in JEA sessions, and so that nothing in the
# rules is ever interpreted as PowerShell.
#
# Settings: { rules: [ { path, depth, include: [], exclude: [], version } ], maxFiles }
# depth is -1 for any depth. Empty include and exclude lists may be left out.
# Settings sent by the probe as base64 encoded UTF-8 JSON
function ConvertFrom-FileInventorySettings {
param([Parameter(Mandatory = $true)] [string]$Base64)
$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($Base64))
return ConvertFrom-Json -InputObject $json
}
# Case-insensitive regular expressions, with a timeout guarding against expressions that never finish
function New-FileInventoryRegexList {
param([object[]]$Patterns, [string]$Rule, [string]$Key)
$options = [Text.RegularExpressions.RegexOptions]::IgnoreCase -bor [Text.RegularExpressions.RegexOptions]::CultureInvariant
$list = [Collections.Generic.List[regex]]::new()
foreach ($pattern in @($Patterns | Where-Object { $null -ne $_ })) {
try {
$list.Add([regex]::new([string]$pattern, $options, [TimeSpan]::FromSeconds(1)))
}
catch {
throw "Invalid $Key regular expression '$pattern' in file inventory rule '$Rule': $($_.Exception.GetBaseException().Message)"
}
}
return ,$list
}
# Rule from the settings, with the folder expanded and the regular expressions compiled
function ConvertTo-FileInventoryRule {
param($Rule)
$path = [string]$Rule.path
$root = [Environment]::ExpandEnvironmentVariables($path)
# Relative paths would depend on the working folder of the session
if ($root -notmatch '^([A-Za-z]:\\|\\\\)') {
throw "File inventory rule '$path' must be a full path such as C:\Folder, expanded to '$root'"
}
$maxDepth = [int]$Rule.depth
if ($maxDepth -lt 0) {
$maxDepth = [int]::MaxValue
}
return [PSCustomObject]@{
Path = $path
Root = $root
MaxDepth = $maxDepth
Include = New-FileInventoryRegexList $Rule.include $path 'include'
Exclude = New-FileInventoryRegexList $Rule.exclude $path 'exclude'
Version = [bool]$Rule.version
# Expressions which have timed out, warned about once each
TimedOut = [Collections.Generic.HashSet[string]]::new()
}
}
# True if the expression matches the name. An expression which times out on the name is treated as not matching, so
# that one slow expression does not fail the whole inventory of the machine.
function Test-FileInventoryRegex {
param($Rule, [regex]$Regex, [string]$Name)
try {
return $Regex.IsMatch($Name)
}
catch {
if ($_.Exception.GetBaseException() -isnot [Text.RegularExpressions.RegexMatchTimeoutException]) {
throw
}
if ($Rule.TimedOut.Add($Regex.ToString())) {
Write-Warning "Regular expression '$Regex' in file inventory rule '$($Rule.Path)' timed out on '$Name' and is treated as not matching"
}
return $false
}
}
# True if the file name is matched by an include expression (or there are none) and by no exclude expression
function Test-FileInventoryName {
param($Rule, [string]$Name)
if ($Rule.Include.Count -gt 0) {
$included = $false
foreach ($regex in $Rule.Include) {
if (Test-FileInventoryRegex $Rule $regex $Name) {
$included = $true
break
}
}
if (-not $included) {
return $false
}
}
foreach ($regex in $Rule.Exclude) {
if (Test-FileInventoryRegex $Rule $regex $Name) {
return $false
}
}
return $true
}
# Text value or null
function ConvertTo-FileInventoryText {
param($Value)
$text = [string]$Value
if ([string]::IsNullOrWhiteSpace($text)) {
return $null
}
return $text.Trim()
}
# Inventory item for a file. The same file on several machines is one asset, so only values which are the same on
# every machine are reported, and the id is the path, version and size of the file without the machine. The machine
# is linked to the file by the custom config, which also hashes the id with the sha256 value transformer.
function ConvertTo-FileInventoryItem {
param([IO.FileInfo]$File, $Rule)
$item = [ordered]@{
name = $File.Name
path = $File.FullName
folder = $File.DirectoryName
extension = ConvertTo-FileInventoryText $File.Extension.TrimStart('.').ToLowerInvariant()
size = $File.Length
}
# Only executables and libraries have a version resource, the fields are empty for other files
if ($Rule.Version) {
$info = $null
try {
$info = [Diagnostics.FileVersionInfo]::GetVersionInfo($File.FullName)
}
catch {
$info = $null
}
if ($null -ne $info) {
# The numeric parts, since the FileVersion text may contain more, such as '10.0.1 (WinBuild.160101.0800)'
if ($info.FileMajorPart -or $info.FileMinorPart -or $info.FileBuildPart -or $info.FilePrivatePart) {
$item.fileVersion = '{0}.{1}.{2}.{3}' -f $info.FileMajorPart, $info.FileMinorPart, $info.FileBuildPart, $info.FilePrivatePart
}
$item.productVersion = ConvertTo-FileInventoryText $info.ProductVersion
$item.productName = ConvertTo-FileInventoryText $info.ProductName
$item.companyName = ConvertTo-FileInventoryText $info.CompanyName
$item.fileDescription = ConvertTo-FileInventoryText $info.FileDescription
}
}
# Path in lower case since Windows paths are case-insensitive, and the version empty when there is none
$item.id = '{0}|{1}|{2}' -f $File.FullName.ToLowerInvariant(), $item.fileVersion, $File.Length
return [PSCustomObject]$item
}
# Validate the rules and report whether their folders exist, as JSON. Used to test credentials, so it must be quick.
function Test-FileInventoryRules {
param([Parameter(Mandatory = $true)] [string]$Settings)
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
$results = @(
foreach ($ruleSettings in @((ConvertFrom-FileInventorySettings $Settings).rules)) {
$rule = ConvertTo-FileInventoryRule $ruleSettings
if ([IO.Directory]::Exists($rule.Root)) {
$status = 'found'
}
else {
$status = 'not found'
}
[PSCustomObject]@{
id = $rule.Path
name = "$($rule.Root) ($status)"
}
}
)
return ConvertTo-Json -InputObject $results -Compress
}
# Files matching the rules, as JSON. Folders are walked breadth first down to the depth of each rule, at most
# maxFiles files are reported per rule. Folders which cannot be read are skipped, as are junctions and symbolic
# links below the rule folder since they could lead outside it or into a loop. A file matched by several rules
# is reported once.
function Get-FileInventory {
param([Parameter(Mandatory = $true)] [string]$Settings)
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
$parsed = ConvertFrom-FileInventorySettings $Settings
$maxFiles = [int]$parsed.maxFiles
$seen = [Collections.Generic.HashSet[string]]::new([StringComparer]::OrdinalIgnoreCase)
$files = [Collections.Generic.List[object]]::new()
foreach ($ruleSettings in @($parsed.rules)) {
$rule = ConvertTo-FileInventoryRule $ruleSettings
# Rule folders may only exist on some machines
if (-not [IO.Directory]::Exists($rule.Root)) {
continue
}
$count = 0
$folders = [Collections.Generic.Queue[object]]::new()
$folders.Enqueue([PSCustomObject]@{ Folder = [IO.DirectoryInfo]::new($rule.Root); Depth = 0 })
while ($folders.Count -gt 0 -and $count -lt $maxFiles) {
$current = $folders.Dequeue()
try {
$entries = $current.Folder.GetFiles()
}
catch {
$entries = @()
}
foreach ($file in $entries) {
if ($count -ge $maxFiles) {
break
}
if (-not (Test-FileInventoryName $rule $file.Name)) {
continue
}
if (-not $seen.Add($file.FullName)) {
continue
}
$files.Add((ConvertTo-FileInventoryItem $file $rule))
$count++
}
if ($current.Depth -lt $rule.MaxDepth) {
try {
$subfolders = $current.Folder.GetDirectories()
}
catch {
$subfolders = @()
}
foreach ($subfolder in $subfolders) {
if (($subfolder.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) {
continue
}
$folders.Enqueue([PSCustomObject]@{ Folder = $subfolder; Depth = $current.Depth + 1 })
}
}
}
}
return ConvertTo-Json -InputObject $files.ToArray() -Depth 2 -Compress
}
Export-ModuleMember -Function Test-FileInventoryRules, Get-FileInventory

  1. Check the Path for typing errors. The credential test shows the path after environment variables are expanded.
  2. Confirm that the folder exists on that target. Folders that only exist on some machines are reported as not found on the others, which is expected.
  3. Confirm that the account can read the folder.
  1. Check that Include matches the file names, not the paths, and that dots are escaped as \..
  2. Check that Exclude does not also match the files.
  3. Check that Subfolders includes the folder levels where the files are.
  4. If a folder holds more matching files than File Inventory Max Files, the files beyond the limit are not reported. Raise the limit or make the row more specific.

The credential test reports an invalid regular expression

Section titled “The credential test reports an invalid regular expression”

The message names the folder row and the expression. Correct the expression in Include or Exclude and test again.

The JEA endpoint does not make the functions available

Section titled “The JEA endpoint does not make the functions available”

Add vScopeFileInventory to ModulesToImport and Test-FileInventoryRules and Get-FileInventory to VisibleFunctions in the role capability file, and check that the module is installed on the target. See Use JEA.

  1. Confirm that Read version is enabled for the folder row.
  2. Only executables, libraries, and some other binary files have a version resource. Other files have empty version values.