Hi,
You can set the number of subdirectory levels using the Depth parameter.
Get-ChildItem -Path 'C:\Logs' -Filter '*.txt' -Depth 1
Best Regards,
Ian Xue
If the Answer is helpful, please click "Accept Answer" and upvote it.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm trying to list all .txt
files in a specific directory using PowerShell on a Windows Server. I don't want to search recursively, but I'm only getting files from the root of the directory and none from subdirectories. Here’s the command I'm using:
powershellCopy code
Get-ChildItem -Path 'C:\Logs' -Filter '*.txt'
Am I missing something, or is there a way to include files from the first level of subdirectories
Hi,
You can set the number of subdirectory levels using the Depth parameter.
Get-ChildItem -Path 'C:\Logs' -Filter '*.txt' -Depth 1
Best Regards,
Ian Xue
If the Answer is helpful, please click "Accept Answer" and upvote it.