I'm pretty new to scripting, as well as to PowerShell. What I'm trying to do is deploy files from one folder (C:\Deployments\QA\QADEP-1504\Processor Handlers\Release) to another folder on a remote server (\HQDEVAPP004\C$\Lonestar\ProcessorHandlers\Test). And within that 'Test' folder, there are 3 subfolders (1, 2, and RejectedTransactionHandler).
So I want all of the files to deploy to folders 1 and 2, but not the RejectedTransactionHandler folder. I've tried using the '-exclude' function but that seems to be only good for files, not folders, but I could be wrong. The files deploy to all three folders every time. Here is what I have so far:
Location of starting directory
$_SourcePath = "C:\Deployments\QA\QADEP-1504\Processor Handlers\Release"
List all folders in local directory
$PH = Get-ChildItem '\\HQDEVAPP004\c$\LoneStar\ProcessorHandlers\Test\' -Directory
Clear-Host
foreach ($folder in $PH.Name) {
Get-ChildItem -recurse ($_SourcePath) | Copy-Item -Destination "\\HQDEVAPP004\C`$\Lonestar\ProcessorHandlers\Test\$folder" -PassThru
}
```