I'm pretty new to Powershell and I'm looking for assistance on creating a script.
I need to run a script to look for 6 file extensions on a Network Drive Folder and subfolder and put into a csv list with the file name and path.
So it would be for x:\Sample Data and all subfolders under that. The file extensions are .las, .lax, .gdb , .dwg, .dxf, .dgn, .shp
Any assistance or help would be greatly appreciated.
CodePudding user response:
You were close!
Try
$includes = '*.las', '*.lax', '*.gdb', '*.dwg', '*.dxf', '*.dgn', '*.shp'
Get-ChildItem -Path 'X:\Sample Data' -Recurse -File -Include $includes |
Select-Object @{Name = 'Path'; Expression = { $_.FullName }} |
Export-Csv -Path 'C:\Powershell\report.csv' -NoTypeInformation
Since you are only storing one property, you might also want to consider saving as simple text file:
$includes = '*.las', '*.lax', '*.gdb', '*.dwg', '*.dxf', '*.dgn', '*.shp'
(Get-ChildItem -Path 'X:\Sample Data' -Recurse -File -Include $includes).FullName |
Set-Content -Path 'C:\Powershell\report.txt'