Public/Find-ComputersFiles.ps1
function Find-ComputersFiles { <# .DESCRIPTION Discover queried files meeting a specific search parameter and output the findings to a spreadsheet. .Parameter computers A list of computers that are being searched .Parameter csvout Path and filename for the CSV report .Parameter include Specify filename being searched for .Parameter Path Patch on the computers that are being search .EXAMPLE Searches computers listed in the text file for pst files and outputs the findings to a spreadsheet. (Computers should be line delimited) find-computersfiles -computers C:\computers.txt -csvout c:\results.csv -include *.pst .EXAMPLE Performs the same function as the first example, except it only searches the specified path and it's subfolders. find-computersfiles -computers C:\computers.txt -csvout c:\results.csv -include *.pst -path "c$\users\*\appdata\local" .Link https://github.com/TheTaylorLee/AdminToolbox #> [CmdletBinding(SupportsShouldProcess)] Param ( #Variable containing computers being queried [Parameter(Position = 0, Mandatory = $true)]$computers, #Variable containing output path for csv file [Parameter(Position = 1, Mandatory = $true)]$csvout, #Variable specifying search parameter [Parameter(Position = 2, Mandatory = $true)]$include, #Variable specifying search parameter [Parameter(Position = 3)]$Path = "c$" ) #Check For Admin Privleges Get-Elevation #Suppress Errors $ErrorActionPreference = 'SilentlyContinue' #Runs to find all files that match the query on all included computers and outputs the results to a CSV Get-Content $computers | ForEach-Object { Get-ChildItem "\\$_\$path" -Include $include -Recurse } | Select-Object Name, Directory, Length, LastAccessTime, LastWriteTime, CreationTime | Export-Csv $csvout -Append -NoTypeInformation #Restores default error action of show $ErrorActionPreference = 'Continue' } |