Pipeline Input in PowerShell

Function Remove-IfEmpty {
	[CmdletBinding()]
	Param(
		[Parameter(ValueFromPipeline)] $dir
	)
	process {
		if (
			(Test-Path $dir.fullname -PathType container) -and 
			((ls $dir.fullname -rec -file | measure | select -expand count) -eq 0)
		) {
			rm $_.fullname -confirm
		}
	}
}

ls -rec -dir | Remove-IfEmpty
ls -dir | select -first 1 | Remove-IfEmpty

Citing this,

reference if process aliases get-process