How do I fix this issue? I am working on a code that will copy all of a single filetype (ie. txt, jpg, etc) to a single location so that I can suss out duplicates and manipulate them in one place. I was finally able to list all the physical drives but the systemroot, search each drive recursively for the files, and list them. Example below:
#TFT - This File Type
#This bit find all hard drives and jump drives, lists files of the extension given
#and returns that list of files.
function tft($ext){
$thisvalue = ($ext)
$just_drives = @(get-psdrive |where root -Like '*`:`\'|where Used* -gt ''|where name -NE 'c')
if($ext -notlike '`*.*'){$ext='*.'+$ext}
$a=foreach($jd in $just_drives){set-location -path $jd.Root;gci $ext -Recurse -Force -ErrorAction SilentlyContinue|where fullname -NotLike '*RECYCLE.BIN*'|ft fullname -autosize -HideTableHeaders
}}
PS:>tft ttf
and the result of it is
PS:>$a [enter]
[truncated for space]
E:\$WINDOWS.~BT\Windows\Boot\Fonts\chs_boot.ttf
E:\$WINDOWS.~BT\Windows\Boot\Fonts\cht_boot.ttf
E:\$WINDOWS.~BT\Windows\Boot\Fonts\jpn_boot.ttf
E:\$WINDOWS.~BT\Windows\Boot\Fonts\kor_boot.ttf
E:\$WINDOWS.~BT\Windows\Boot\Fonts\malgunn_boot.ttf
...
H:\WINX21H2\efi\microsoft\boot\fonts\segoe_slboot.ttf
H:\WINX21H2\efi\microsoft\boot\fonts\wgl4_boot.ttf
H:\WINX21H2\sources\segoeui.ttf
Awesome! Code worked perfectly. Well... Until I try to manipulate that listing.
PS:> write-host $a -join(',')
Microsoft.PowerShell.Commands.Internal.Format.FormatStartData,Microsoft.PowerShell.Commands.Internal.Format.GroupStartData,Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData,Microsoft.PowerShell.Commands.Internal.Format...
PS:> $a|copy-item d:\
copy : The input object cannot be bound to any parameters for the command either because the command does not take
pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
At line:1 char:4
+ $a|copy d:\
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power...FormatStartData:PSObject) [Copy-Item], ParameterBin
dingException
+ FullyQualifiedErrorId : InputObjectNotBound,Microsoft.PowerShell.Commands.CopyItemCommand....
... for 337K+ lines!!!
Long winded, I know and it may have been answered elswhere but for all my searches I could not find the key. Everything I try returns the object and not the text.
Looks to me like the final pipeline item you have is an ft
, so the output object is a formatted table, not the objects you want.
I'd remove this and give it another go:
|ft fullname -autosize -HideTableHeaders