We have a situation where the cp.exe and cp.dll are getting copied in build artifacts of all the folders and we want them only to be part of PS.Manager.Service and PS.A.Service folder/Artifacts.
From rest all the folders both the cp.exe and its cp.dll must be deleted. I tried doing that with the below script but It is not working. I am not sure what am I missing here.
Any suggestions would really help.
Thanks.
$SourceDirectory = "e:\cache\Agent03\2\s"
$EXcludeManagerFolder = "e:\cache\Agent03\2\s\PS.Manager.Service"
$EXcludeAFolder = "e:\cache\Agent03\2\s\PS.A.Service"
gci -path "$SourceDirectory" -Include "cp.exe, cp.dll" -Exclude "$EXcludeManagerFolder","$EXcludeAFolder " -Recurse -Force | Remove-Item -Recurse -Force