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