Author Posts

September 28, 2017 at 6:14 pm

I have an application that has a bat file which can be ran which exports the configuration of the application to a directory named conf-exported. When it is ran, it creates a subdirectory in conf-exported named with a date time stamp format. For example, YYYYMMDDHHMMSS. I can automated the batch file to run daily in order to have the application configuration backed up daily. What I would like to do is move the subdirectory to another server. A copy is not good because the configuration contains encrypted credentials which may not work if I try to use the configuration on another server.

Is there a simple way to do this in Powershell and create and update a log each time the subdirectory has been moved. Please advise. Thank you.

September 29, 2017 at 7:25 pm

Move-Item is the cmdlet you want to use.

September 29, 2017 at 8:09 pm

I think I may be able to use ROBOCOPY instead. I will test and see. Thanks.

October 2, 2017 at 3:18 pm

Well, you indeed should use RoboCopy for this but not because that's easier and you are a beginner at Powershell.
It's just the right tool for the job. You could create a BAT file with something that looks like this:

set tdate=%date: =%
set tdate=%tdate:/=%
set ttime=%time::=%
set ttime=%ttime:.=%
set ttime=%ttime: =%

echo off
Robocopy \\ServerA\Folder1 \\ServerB\Folder1 /COPYALL /MOVE /R:2 /W:1 /log:c:\robocopy\AT_%tdate%-%ttime%_transferFiles.txt /v /tee /fp /eta

So this way, each job would have a unique filename that has the date on which it was executed.
You can lookup the parameters yourself (,
these are the ones i use mostly. It adds some visibility when you run them manually. In the scope of the script, some aren't as useful since you won't ever look at it.

For reference:

Moves files, and deletes them from the source after they are copied.
Moves files and directories, and deletes them from the source after they are copied.

October 2, 2017 at 5:24 pm

Thank you. I try to open the link you provided, but it does not open for me.

October 3, 2017 at 10:31 am

thats because the extension fell of for some reason.