How to create folders on a Windows machine using PowerShell

The below script can be used to create folders on a windows machine. This script takes a list of folders and locations in an array and loops through it to create folders. Make sure you update the machine’s name on which you want to run this script in the TARGET_MACHINE_NAME variable.

This script will skip the directory creation if the directory already exists.

How to replicate/copy files and folder structure between two different Windows based machines using PowerShell.

Many times we feel the need of copying files between two machines and also keeping the same folder structure between two machines. For example, consider the following use cases:

  1. Replicating the production/non-production environment’s directory structure on a blank virtual machine.
  2. Copying files and folders from one location to another location.
  3. Copying files from production/non-production machine to your local machine.

Now to solve the above problem, I have created a PowerShell script that can replicate a given list of directories present on the source machine to another target machine. I have also added an option to choose if we want to just replicate the folder structure to the target machine or we want to copy the files present in those folders too.