- Open the PowerShell ISE → Create a new script using the following code. In the $filename variable, specify a string that might indicate the file contains sensitive data, and for $searchinfolder, specify the directory or folder to search in.
$filename = '*payroll*.*'#you can use wildcards here for name and for extension
$searchinfolder = '\\pdc\Shared\Accounting*'
Get-ChildItem -Path $searchinfolder -Filter $filename -Recurse | %{$_.FullName}
- Run the script.
- Review the results:

Once you have a list of files that might contain sensitive data, you might want to move them to a secure location. However, the Windows PowerShell script you create to process the files will terminate with an error if the path is invalid, so you should check whether the files and folders still exist before you run it. The following commands will help:
- To check whether a file exists, run the following script, specifying the filename in the $checkpath string:
$checkpath = 'C:\Shared\Accounting\Payroll 2016-2017.xlsx'
Test-Path -Path $checkpath
- To determine whether there are any files in C:\Shared\Accounting\ with the .xlsx extension, run following code on your computer:
Test-Path -Path "C:\Shared\Accounting\*" -Include *.xlsx
Note that you can use environment variables with the test-path statement. The example below shows how to detect if the $profile variable leads to a directory or a file:
Test-Path $profile -Pathtype Leaf
- Run Netwrix Auditor → Navigate to "Reports" → Open "User Behavior and Blind Spot Analysis" → Go to "Information Disclosure" → Select "File Names Containing Sensitive Data" → Click "View".
- Specify the following filters and parameters:
- Object UNC Path – Specify the path to your file share (example: "\\server\share")
- Disallowed Words – Specify the name of the file you want to search (example: "payroll")
- Click "View Report".
To save the report, click the "Export" button → Select a format, such as PDF → Click "Save as" → Choose a location to save it.
