Powershell: mover archivos de forma recursiva

stoy tratando de copiar todos los archivos y carpetas de salida de compilación en unaCompartimient carpeta OutputDir / Bin) excepto algunos archivos que permanecen en la OutputDir. LosCompartimienta carpeta @ nunca se eliminará.

Condición inicial

Output
   config.log4net
   file1.txt
   file2.txt
   file3.dll
   ProjectXXX.exe
   en
      foo.txt
   fr
      foo.txt
   de
      foo.txt

Objetivo

Output
   Bin
      file1.txt
      file2.txt
      file3.dll
      en
         foo.txt
      fr
         foo.txt
      de
         foo.txt
   config.log4net
   ProjectXXX.exe

Mi primer intento:

$binaries = $args[0]
$binFolderName = "bin"
$binFolderPath = Join-Path $binaries $binFolderName

New-Item $binFolderPath -ItemType Directory

Get-Childitem -Path $binaries | ? {$_.Name -notlike "ProjectXXX.*" -and $_.Name -ne "config.log4net" -and $_.Name -ne $binFolderName }  | Move-Item -Destination $binFolderPath

Esto no funciona, porqueMove-Item no puede sobrescribir carpetas.

Mi segundo intento:

function MoveItemsInDirectory {
    param([Parameter(Mandatory=$true, Position=0)][System.String]$SourceDirectoryPath,
          [Parameter(Mandatory=$true, Position=1)][System.String]$DestinationDirectoryPath,
          [Parameter(Mandatory=$false, Position=2)][System.Array]$ExcludeFiles)
    Get-ChildItem -Path $SourceDirectoryPath -Exclude $ExcludeFiles | %{
        if ($_ -is [System.IO.FileInfo]) {
            $newFilePath = Join-Path $DestinationDirectoryPath $_.Name
            xcopy $_.FullName $newFilePath /Y
            Remove-Item $_ -Force -Confirm:$false
        }
        else
        {
            $folderName = $_.Name
            $folderPath = Join-Path $DestinationDirectoryPath $folderName

            MoveItemsInDirectory -SourceDirectoryPath $_.FullName -DestinationDirectoryPath $folderPath -ExcludeFiles $ExcludeFiles
            Remove-Item $_ -Force -Confirm:$false
        }
    }
}

$binaries = $args[0]
$binFolderName = "bin"
$binFolderPath = Join-Path $binaries $binFolderName
$excludeFiles = @("ProjectXXX.*", "config.log4net", $binFolderName)

MoveItemsInDirectory $binaries $binFolderPath $excludeFiles

Existe alguna forma alternativa de mover archivos de forma recursiva de una manera más fácil con PowerShell?

Respuestas a la pregunta(4)

Su respuesta a la pregunta