I am currently extracting the Name, FullName, BaseName from file's in a directory into a text file. I am also wanting to extract the 'Comments' field from the properties of the files I am looking at to the same text file.
Is this possible with Get-ChildItem or would I need to use something different?
Get-ChildItem "\\otahnas02\TCG\Embroidery" | Select Name, FullName, BaseName,
@{ n = 'Folder'; e = { Convert-Path $_.PSParentPath } }, `
@{ n = 'Foldername'; e = { ($_.PSPath -split '[\\]')[-2] } } | Sort-Object name |
Export-Csv "\\nzsdf01\c$\SCRIPTS\EmbroideryUpdateDirectory.txt" -Encoding Utf8 -NoTypeInformation
I have tried adding Comments to the select of the script, although this doesn't work. I'm guessing the Comments property isn't part of Get-ChildItem? Not a powershell expert.
The below selects the Comments field and all other properties I need. Sorting the list by name.
Get-FileMetaData -folder "C:\pics" | select 'Name', 'Path', 'Comments' | Sort-Object Name |
Export-CSV "C:\pics\textfile.csv" -encoding Utf8 -NoTypeInformation
Only issue is this takes more time to execute than my original code.