Reputation: 13
Trying to get a list of directories that contain .123 files. Just need the directory Name \ Path. Have tried Get-ChildItem with many options
get-childitem -Directory -Recurse -Filter *.123 |Select-Object FullName
Would like to output to a CSV file.
Thanks
Upvotes: 1
Views: 585
Reputation: 1192
The following should give you the output you want
Get-childitem -Recurse -Filter *123 | select-object directory -Unique | Export-Csv -Path file.csv
Notice that we are looking for files, so no -directory
switch is needed, and then we can select the directory property of the file.
The -unique
switch will prevent us getting the same directory multiple times if it contains more than one file with your filter option.
Upvotes: 3