Ask a question

Ron Camerata

Pushing out a file to some workstations on a domin

I need to do a one time update for a file that is used most of the workstations on a network.  Basically replace an existing file.

I don't know of a way to do this on certain computers only with GPO.

Does anybody have a script or power shell command that could do this?


asked03/01/2019 15:43
36 views
Add Comment
Host

Microsoft MVP

Hello Ron,

Do you know the source location and the destination? If so then you can copy that from a logon script. Something like this:

copy \\servername\sharename\filename.txt c:\somelocalfolder\filename.txt /y

 

Ron Camerata

That could work!  I do know the source and destination locations.

But I was hoping for something like a shingle command that would send it to all of the workstations and only install it on the ones that had the old file.


replied 03/01/2019 16:22
Mariette Knap

Microsoft MVP

Alright! We need to make a fancy script. What we can do is define the computername like comp1,comp2 etcetra and then run Foreach do something. Or we can make it even fancier and pull all computers from a certain OU in the AD and run the same command.


replied 03/01/2019 16:40
Chris Currell

There are a few ways to do this. I prefer using the logon script to all another batch file.  We have also sent out an email to users with a link in the email to the batch file. It needs to be nothing more than, Click here to run the update."

The DOS command you want to play with is If Exist. You can open and cmd window and type help If to read more. But here are a few examples of how to use it.

  • if exist (
    • rem file does exist
    • copy \\servername\sharename\filename.txt c:\somelocalfolder\filename.txt /y
  • ) else (
    • rem file doesn't exist
    • enter code here if you want to do something different. maybe a marker to show the script ran.
  • )
You can also use one line to do this:
 
if exist  copy \\servername\sharename\filename.txt c:\somelocalfolder\filename.txt /y
 
You may have to play with using quotations around your path if they contain spaces or long file names. Some times we have had to revert to 8.3 file names.
 
Good luck

replied 03/15/2019 20:04
Mariette Knap

Awesome answer Chris!


replied 03/16/2019 16:02
Last Activity 03/20/2019 12:25

No answers found

Add an Answer