I have code that looks for folders and afterwards it looks for the criteria I am telling it. So far so good. Then I got a ForEach-Object with a Copy-Item $_.Fullname in it. The code itself is working and spitting no errors, but I don't want to copy the folder itself + its content. I just want to copy the content of the folder. I already tried things like $_.Fullname/* and so on.
Here's how my code looks like:
Get-ChildItem -Path $DestinationBackup | Where {
$_.Name -like "$BackupName_Differential3*"
} | ForEach-Object {
Copy-Item -Path $_.FullName -Recurse -Destination $Differential_Destination -Force
}
Edit 1:
My Folder structure looks like this:
M143 ← (Root Folder) ├─Backups ← (Folder, here are Backups stored) │ ├─Fullbackup... │ ├─Incrementalbackup... ← Copy Content of this folder, without folder) │ └─Differentialbackup... ← (Into this folder) └─Backup_Script.ps1
Get-ChildItem -Path "$DestinationBackup\*" | ...?