Moving Files across the network…for 2000 machines – Part II

In my previous post, I showed how we solved a problem to move files for 2000 machines using a community function called Split-Job, that runs using runspaces.

I was talking with  the PowerShell Jedi Johan Akerstrom , and another approach could be used as well. In this case, not running in asynchronous mode, but in parallel using workflows. This approach only works in PowerShell 3.0 and 4.0, instead of using Split-Job, that will works in Posh 2.0,3.0 and 4.0.

Workflows implicit works with PowerShell Remoting, and in the environment  of my friend, it was disabled. But in his case we are using the shared path to perform the operation in the machine, so I will not need to use remoting in the machines.

The code is

Workflow Move-LargeFiles {
        [String[]] $Computername

    Parallel {

        foreach -parallel ($Computers in $Computername) {
            inlinescript {
                Write-Verbose -message “Processing Computer $($using:computers)”
                Get-ChildItem “\\$using:computers\X$\foo\foo1\” -file |
                Where { ($_.Length/1MB) -gt X } |
                Move-Item  -destination \\FixedPath\foo\LargeFiles
                Write-Verbose -message “Computer $($using:computers) Finished”



Move-LargeFiles -Computername (get-content c:\temp\servers.txt) –Verbose

To be honest I don’t know the difference in time between the two approaches, but both certainly are better than sequentially 🙂

In this case we are only  using workflow to have the feature of run in parallel

As Johan says, there is more than one way to skin a cat 🙂

About Laerte Junior

Laerte Junior Laerte Junior is a SQL Server specialist and an active member of WW SQL Server and the Windows PowerShell community. He also is a huge Star Wars fan (yes, he has the Darth Vader´s Helmet with the voice changer). He has a passion for DC comics and living the simple life. "May The Force be with all of us"
This entry was posted in Algo que Esqueci de Categorizar. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s