Script to copy 1 folder to multiple computers

Here’s what I have:

$computers = Get-Content “C:\users\dbrooks\desktop\computers.txt”
$fileToCopy = “C:\users\dbrooks\desktop\Training Survey 2015.pdf”
ForEach($computer in $Computers){
Copy-Item -Path $fileToCopy -Destination “C:\users*\desktop”

I’m assuming I can’t use a wildcard for users here. The PC’s are stored in a text file on individual lines, and all PC’s are local - none are remote. It’s a classroom environment.

How would you recommend I continue?

For Windows 7 and 8 machines, you could use C:\Users\Public\Desktop as your target.

First off, don’t assume you can’t use wildcards with the -Destination parameter. It’s in the help: All you have to do is enter Get-Help Copy-Item -ShowWindow and scroll down to the -Destination parameter. Although your assumption is correct (this time ;)), you never had to assume in the first place.

I saw your same problem posted somewhere else too, and I’m having a little problem following, especially when you said the PCs are local and not remote. Do you intend to run the script on one computer and have it copy the file to the other computers? If so, then the PCs in your classroom are in fact remote (even if you can see them from your desk). There’s only one local computer, and that’s the one you’re using. If they are remote, then you may need your destination to be a UNC ("\$computer\C$\Users…"). I just noticed, you don’t even use your $computer variable inside your Foreach statement. Notice that in the UNC partial example I just wrote, that it was actually included.

I rather like Will’s suggestion–one document for all the users instead of the same document for each. If you did this your way, then new users would never see the document unless you reran your script. And then what happens when the document is updated? It would be much easier to replace one document then all of the them. Something to consider. Good luck!