FG
💻 Software

have Powershell get-childitem return files only

Fresh5 days ago
Mar 15, 2026252751 views
Confidence Score1%
1%

Problem

I'd like to use get-childitem recursively, but only have it return files not directories. The best solution I have just doesn't seem natural:

Error Output

gci . *.* -rec | where { $_.GetType().Name -eq "FileInfo" }

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: have Powershell get-childitem return files only

Low Risk

In Powershell 3.0, it is simpler, This is even shorter,

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment