Robocopies in a one powershell script?

How can I run these three command line robocopies in a one powershell script?

robocopy \\server1\folder1 \\server2\folder1 /copyall /e /xo /fft /w:1 /r:1 /sec /z  /MIR
robocopy \\server1\folder2 \\server2\folder2 /copyall /e /xo /fft /w:1 /r:1 /sec /z  /MIR
robocopy \\server1\folder3 \\server2\folder3 /copyall /e /xo /fft /w:1 /r:1 /sec /z /MIR
355LT1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SubsunCommented:
Yes you can... Simply add it as it is, it should work...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
unknown_routineCommented:
Copy your lines of code to a PSL file for example:

test.psl and then double click on this file,



Before doing above make sure your execution policy is not restricted:

In power shell woindow type:
Set-ExecutionPolicy RemoteSigned
Restricted


If you see restricted then set execution policy to remote signed


PS C:\> Set-ExecutionPolicy RemoteSigned
0
SubsunCommented:
@unknown_routine, it's not .PSL it's .ps1

test.psl and then double click on this file,
PowerShell will not execute the script when you double click it, it's a security feature/measure!

You may need to refer this article on 'Running Windows PowerShell Scripts'
http://technet.microsoft.com/en-us/library/ee176949.aspx
0
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Of course you can make it more smart:
In cmd.exe batches:
@echo off
for %%D in (folder1 folder2 folder3) do robocopy \\server1\%%D \\server2\%%D /copyall /e /xo /fft /w:1 /r:1 /sec /z  /MIR

Open in new window

and in PS similar:
'folder1', 'folder2', 'folder3' | % { robocopy \\server1\$_ \\server2\$_ /copyall /e /xo /fft /w:1 /r:1 /sec /z  /MIR }

Open in new window

Both gets more useful the more folders you need to process.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.