r/PowerShell • u/SkullyRed • Jan 12 '26
Google solutions
Google search: find all files under 5mb mp3
This is what a Google search produced as a powershell command/script:
$( $Files = Get-ChildItem -Path "\\PC\Users\name\Music" -Recurse -Filter *.mp3 | Where-Object {$_.Length -lt 5MB} | Sort-Object Length) $Files | ForEach-Object { "$($_.FullName) - $(\'{0:N2}\' -f ($_.Length/1Kb))Kb" } >>C:\tmp\output.txt
The result:
At C:\Users\mike\Desktop\PowerShell\MP3 Under 5MB.ps1:1 char:143
+ ... Where-Object {$_.Length -lt 5MB} | Sort-Object Length) $Files | ForEa ...
+ ~~~~~~
Unexpected token '$Files' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
My powershell prowess score from 1-10 is (.05+/-).
I Ctrl-C, Ctrl-V, modify, save, run. In other words, I'm no programmer or powershell expert.
Why does this not work?
View all comments
Show parent comment
1
u/SkullyRed Jan 13 '26
Perfection!
Thanks to everyone for helping an old man out.
I worked in IT for 37 years but became a "paper pusher" for the last 10. This stuff changes daily it seems. It's hard to keep up when you're not in the trenches.