I'm new to PowerShell and trying to recursively find XML files in a directory and read (or cat
in unix) each file.
If this were a linux machine, I'd do something like:
$ find /path/to/dir/ -type f -iname *.xml -exec cat {} \;
I've been trying PowerShell's Get-Content
and Get-ChildItem
but I'm not having much luck:
powershell Get-ChildItem -Path C:\ProgramData\Microsoft\ -Include *.xml -Recurse | ForEach-Object {Write-Output $_; Get-Content $_}
Could someone help me figure out what I'm doing wrong or offer a simpler solution for finding and recursively reading files in a directory?