powershellfile-listing

Scan out a folder + subfolder + get the files with a specific extension in PowerShell


I have a folder named LOGFILES with a subfolder named LOGFILES_OLD.

enter image description here

But we need to assume that I don't know the contents of the folder.

What I'm trying to develop in PowerShell is a method to show a list of all files with a .log extension.

I have failed to get it with something I have found here:

Get-Item C:\LOGFILES -Recurse | Where-Object {$_.Extension -eq ".log"} | Format-List

Solution

  • Why don't you use :

    Get-ChildItem "C:\LOGFILES"  -include *.log -Recurse