Had this question today and I wasn’t sure how this could be done either. It’s one of those things that you would expect to know but unless you have actually had a use case is never thought about.
[string]$myDir = "C:\Temp\empty"
if ( Get-ChildItem $myDir | Select-Object PSChildName )
{
Write-Output "Directory has the following children:"
Get-ChildItem $myDir | Select-Object -ExpandProperty PSChildName
} else {
Write-Output "Directory is empty."
} #end if
PSChildName is a NoteProperty which contains all the children of the directory as a System.Array of strings rather than file system objects. So unfortunately you cannot then take actions on the resulting child items or for that matter determine which children are directories as opposed to files.
Sure you can recreate the file system path then take action however it is not as nice as if it actually returned file system objects.