I need to format, add text to, a list of files I am getting using Powershell. I can simply use the following script to get my list of files:
Get-ChildItem("c:\path") | where {$_.Length -eq 0} | select name
This works well returning a list of file names:
file1.txt
file2.txt
file2.txt
What I am trying to do is add additional text to the output so it looks more like this:
'file1.txt',
'file2.txt',
'file3.txt',
This I am finding to be more difficult than it should be. I tried this:
$l = Get-ChildItem("c:\path") | where {$_.Length -eq 0} | select name | foreach($_) { "'$_,"}
This doesn't quite do it, as the field name is added to the output:
'@{Name=file1.txt}.Name',
'@{Name=file2.txt}.Name',
'@{Name=file3.txt}.Name',
Is there a way to format this better or remove the object information?