Search code examples
windowspowershellpowershell-3.0

Get application/program which created a file in PowerShell


I have several programs (.exe) installed on my computer which create ".dat" files. One of them creates very large files.

I want to delete only the files created by this program.

Is there a way in PS to know which program has created a file?

I try to filter them in following code:

Get-ChildItem $path -Filter "*.dat" -Recurse -Force |'
Where-Object {$_.CreationTime -lt $limit -and $_.LastAccessTime -lt $limit2 -and $_.Attributes -notmatch "Offline" } |'
Remove-Item -Force

Solution

  • This is not possible unless your program somehow stamps a property onto .dat file which you would then read.

    Use Process Explorer if you want to find out which executable creates the file in question.