function movedata {
param ($sourcePath, $targetPath, $files, $newPath)
$sourcePath = \\host-name\share-name\file_path
Write-Output "$sourcePath"
$targetPath = \\host-name\share-name\file_path
Write-Output "$targetPath"
$files = Get-ChildItem $sourcePath -Recurse | Where-Object { $_.LastWriteTime -gt (get-date).date }
$newPath = Join-Path -Path $targetPath -ChildPath ($_.LastWriteTime)
if (!(Test-Path -Path $newPath)) {
Write-Output "Creating directory $newPath"
New-Item -Path $newPath -ItemType Directory
}
Compress-Archive -DestinationPath $targetPath.zip
Write-Output "$files"
Write-Output "Starting copy"
ForEach-Object {Move-Item -path $sourcePath -destination $targetPath}
Write-Output "$files copied to $targetPath"
}
This scripts purpose is to move data (recursively) by date modified across environments.
I recognize that function. Not sure if this resolves your issue or not. Could you elaborate?