Note: use * after specified location else it will return an empty result.Ĭool Tip: How to add a newline to string or variable in PowerShell! PowerShell Get Childitem Exclude Folders txt, Include parameters, looking for files having multiple extensions, and returning results. In the above PowerShell GCI command, we have specified multiple extensions like. Get-ChildItem -Path D:\PowerShell\* -Include *.zip,*.txt zip, using PowerShell Get-ChildItem cmdlet – Include parameter, it gets input as multiple extensions and returns files. Let’s consider an example to get files having extension. In the above PowerShell GCI example, the get-childitem Recurse parameter along with -Force gets all files in directory and subdirectories.Ĭool Tip: Learn how to get aduser using userprincipalname! PowerShell Get Childitem Include Multiple Extensions Get-ChildItem -Path D:\PowerShell\ -Recurse -Force -File
Recurse parameter search for all files in directory and subdirectories.
If you want to get all files in directory and subdirectories, use the PowerShell Get-ChildItem Recurse parameter. In the above, using PowerShell GCI command get childitem file size only using the Length property. You can use Get-ChildItem alias PowerShell GCI to get the file name from the directory as below Gci -Path D:\PowerShell -File | Select Name PowerShell Get ChildItem File Size only Get-ChildItem -Path D:\PowerShell -File | Select Length In the above example, PowerShell get-childitem command gets the file name only using Name property and location specified by -Path parameter. In the above script, PowerShell gci gets files only from the specified directory.Ĭool Tip: How to get file creation date in PowerShell! PowerShell Get-ChildItem File Name PS C:\> Get-ChildItem -Path D:\PowerShell -File | Select Name Use the following command to get results as above PS C:\> gci -Path D:\PowerShell\ -File