pipe variable to copy-item destination

I want to declare a variable with a list of computer names. For each one i want to stop a service copy a file to c:\windows\ and then start the service.

One example i tried was:

$target = get-content C:\comp2.txt
foreach ($t in $target){
stop-service -Name ‘CDCA Multi Client’;
Copy-Item C:\multi.ini -Destination \$T\c$\windows;
start-service -Name ‘CDCA Multi Client’
}

Another way i tried was:
$target = get-content C:\comp2.txt
$target | ForEach-Object(Invoke-Command {stop-service ‘CDCA Multi Client’}, Copy-Item C:\multi.ini -Destination \$_.T\c$\windows;

what i cant figure out is how to use the data from the pipeline to set the destination path

Why do you have the semicolon at the end

This worked:

$target = get-content C:\comp2.txt
foreach ($t in $target){
Stop-Service -Name wuauserv
Copy-Item C:\Test\ActOffice.txt “\$target\c$\Test”
Get-Service
Start-Service -Name wuauserv
Get-Service
}

Using the parentheses in “\$target\c$\Test” will replace $target with the current computer name from the text file, that’s how you can get the current object in the pipeline to set the destination path. No need for semicolon.