Using PowerShell to update a local folder from a central location

Share this:

In this Tutorial we will use PowerShell to update a local folder from a central repository using versioning control. You may be wondering what is the benefits, well it all depends of the scenario. In the customer that requested this feature is a large company with several sites and they want the ability for the local administrators to have some basic scripts and tools locally, and that is the idea of this Tutorial.

Another good example is for Exchange Administrators, let’s say we want to keep consistency with all scripts + CU locally before performing a troubleshoot, this script could be used for that as well.


Let’s keep it simple, first let’s use only two files at the Domain Controllers in the NETLOGON which is replicated among all Domain Controllers. We will use a file for control named and a second file which will be the script that the administrator will run locally to update his local copy with a central location and that file will be called Script-Update.ps1.


In order to keep consistency, we could use Group Policies to create a folder o the C: root of each Server, for this example we will use the folder yOperations to be the location to be local folder with all scripts and tools. Another thing that we can do is to copy the Script-Update.ps1 file to the C:yOperations folder using the administrator logon script.

The file…

This file is the responsible for versioning control, we will have two columns initially: Version and Repository. The first one is self-explanatory and the second one is the location of the central repository, this way we don’t need to touch the script in case we change the central location.


The Script…

Bear in mind that I’m an IT Pro and not a developer :), so any improvements you can use the comments area and I will be glad to update this post to reflect the changes. Basically we test to see if the local and remote version of the exist and if they are different then we will trigger a copy from the central location to the local folder.

Note: For this Tutorial the administrator is the responsible to run the Script-Update.ps1 to update the local folder on the server.


How to use the script…

We made it simple as possible, and there are only two outputs. The first one is when the local version is up-to-date, then the following message will be displayed.


The second is when there is a newer version, then the following output will be displayed and the local folder will receive the new files.


How it works…

Let’s say that our corporate team added 3 new tools to be used by the administrators (which are the Tool01, Tool02 and Tool03).


Now, the administrator just need to go to the control file ( and update the value for the version, in this case we replace the previous value which was 4 to 5, then save the file.


Now, when an administrator is logged on the server, he can run the Script-Update.ps1 and the message below will be displayed and all the tools in the central repository will be copied locally.



In this Tutorial we show a simple script that uses a control file to copy files from a central location, a similar process can be used for several other tasks.

Written by Anderson Patricio

Anderson Patricio

Anderson Patricio is a Canadian MVP in Cloud and Datacenter Management, and Office Server and Services, besides the Microsoft Award he also holds a Solutions Master (MCSM) in Exchange and several other certifications. Anderson has been contributing to the Microsoft Community with articles, tutorials, blog posts, twitter, forums and book reviews. He is a regular contributor here at,, and Anderson (Portuguese).

Related Post

How to connect to Microsoft Azure using PowerShell In Today’s tutorial, we are going over the process to connect your Windows 10/Windows Server 2016 in Microsoft Azure to manage your tenant. In the ...
Managing Hyper-V Server remotely through PowerShel... Working with PowerShell can be very common for daily tasks and Hyper-V Server management. However, as there is more than one server to be managed, som...
Listing the drive letters, size and free space usi... Using PowerShell, the administrator is able to retrieve a lot of information from the operating system. In Today’s Tutorial, we are going the process ...
Performing Backup on your DHCP Server In this Tutorial we will be checking the process to protect the DHCP Server database using the automatic configuration, Graphical User Interface and P...