New to Powershell - Please Help

In short - I believe Powershell can achieve what is needed but I'm not sure how to compile the script. 
I have roughly 2k directories including multiple levels of subdirectories. I would like to achieve the following:
1. Identify all directories with 4 files or less within.
2. Move found files to a directory "c:\DumpDir".
3. "Cleanup" Delete all empty directories.
4. Print report "not required" just a desire.
After 4hrs of research I've only been able to come up with the identification piece, but when I try to include the move function things get odd. I finally admitted defeat and thought it best to seek help.
"(gci C:\bends\ -r | ? {$_.PSIsContainer -eq $True}) | ? {$_.GetFiles().Count -eq 4} | select FullName"
Thank you,
Chris

You are getting directories but you want to move files. Use the directory  to call the Get-ChildItem with the directory name:
Get-ChildItem C:\temp -Directory -Recurse |
Where {$_.GetFiles().Count -eq 4} |
Get-ChildItem -File |
Move-Item -Destination c:\temp -WhatIf
¯\_(ツ)_/¯

Similar Messages

Maybe you are looking for