Return only files with Get-childitem in powershell 2
14,690
You could use the Where-Object cmdlet to check the PSIsContainer
property:
Get-ChildItem | Where-Object { !$_.PSIsContainer }
Author by
Zakaria Belghiti
Hello friends, I am a computer engineering student at ENSAT, web developer, passionate about new technologies, and an ambitious guy aspiring to enrich the world.
Updated on June 13, 2022Comments
-
Zakaria Belghiti almost 2 years
I know that we can use the parameter -File in Powershell V3.0 but how can we get only files with the Get-childitem cmdlet in Powershell V2 ?
-
Zakaria Belghiti almost 8 yearsOkay I'll try it, but does it work for not named files too?
-
Martin Brandl almost 8 yearswhat do you mean with not named files?
-
Zakaria Belghiti almost 8 yearsI mean files without extension
-
Martin Brandl almost 8 yearsYes, it will also include files without extensions.
-
Matt almost 8 yearsPretty sure you need to use brackets in v2.
-
Martin Brandl almost 8 yearsOh, thanks Matt, I updated my answer.