And to clarify, I don't think any of this solves the OP's actual problem. That would certainly require more from the script. But I just remember banging my head with -contains in the past and wanted to save some poor soul some time.
B
Latest posts made by bwinc
- 
RE: Need a Powershell script to move these filesposted in IT Discussion
 - 
RE: Need a Powershell script to move these filesposted in IT Discussion
With all due to respect, I don't think that script would work.
help about_comparison_operatorsstates-contains"Returns true when reference value contained in a collection". So it wouldn't apply here. I remember this tripping me up in the past.-matchis what you're looking for. Specifically I'd use-imatchfor a case-insensitive match.And if I may, here are couple other things I'd change.
I'd join these two lines together:
$folders = Get-ChildItem -Path $baseFolder -Directory | Where-Object -Property Name -imatch $matchStringRather than manually concatenating the destination path, I'd use the
Join-Pathcmdlet. And since there are more than two parameters I'd use a splat.foreach ($folder in $folders) { $copyParams = @{ Path = $folder.FullName Destination = Join-Path -Path $destFolder -ChildPath $folder.Name Recurse = $true } Copy-item @copyParams }Hope this helps!