Windows Vista Forums

Can Powershell help me automate this?
  1. #1


    Gary Guest

    Can Powershell help me automate this?

    I routinely copy a lot of files between different servers via robocopy, and I
    was wondering if there is a better way to create and monitor the copy jobs.
    What I currently do is manually create a batch file (see example below), and
    then run it in the console session of the server via RDP.
    This lets me logon periodically and check how the copies are going.
    (We're talking an average of 50-100 CMD windows and terabytes of files, so
    it takes quite a while)

    Is there an easy way to:

    1. Automate building the batch file or creating an equivalent?
    (The robocopy needs to run from the destination server, in a session
    that is not affected by anyone logging onto the server, and there can be more
    than 100 shares that need to be copied, but I try to limit the number of
    concurrent sessions to 100 or less for performance)



    2. Monitor the progress of the operation?
    (Overall percentage complete would be great, but even seeing something
    like "23 of 84 sessions complete" would be helpful.)


    start cmd.exe /c robocopy \\server1\$drivename\sharename\sharename1
    drivename\sharename\sharename1 <lots of robocopy parameters go here>
    start cmd.exe /c robocopy \\server1\$drivename\sharename\sharename2
    drivename\sharename\sharename2 <lots of robocopy parameters go here>
    etc...........
    etc...........

      My System SpecsSystem Spec

  2. #2


    Marco Shaw [MVP] Guest

    Re: Can Powershell help me automate this?

    I think the others have provided some good input.

    My 2 cents:
    1. PowerShell can help automate the batch file creating if there's some kind
    of pattern that can be followed. You might need to detail a bit more of
    what the full commands needs to look like.

    2. As for monitoring, assuming the commands are meant to be synchronous,
    then it would be a simple matter of using some logic between each command to
    increment the number of commands completed.

    Are you restricted to using PowerShell v1? If you need to run these jobs
    asynchronously, then you can run each robocopy command in a background job.

    BITS is definitely an option here, and your scenario would be a good test.
    Very long running background jobs would also be a good test for PowerShell.

    If you can provide more details, maybe we can provide more guidance.

    Marco

    "Gary" <Gary@xxxxxx> wrote in message
    news:6228A679-9AEE-4DC1-8C39-A86634711695@xxxxxx

    > I routinely copy a lot of files between different servers via robocopy,
    > and I
    > was wondering if there is a better way to create and monitor the copy
    > jobs.
    > What I currently do is manually create a batch file (see example below),
    > and
    > then run it in the console session of the server via RDP.
    > This lets me logon periodically and check how the copies are going.
    > (We're talking an average of 50-100 CMD windows and terabytes of files, so
    > it takes quite a while)
    >
    > Is there an easy way to:
    >
    > 1. Automate building the batch file or creating an equivalent?
    > (The robocopy needs to run from the destination server, in a session
    > that is not affected by anyone logging onto the server, and there can be
    > more
    > than 100 shares that need to be copied, but I try to limit the number of
    > concurrent sessions to 100 or less for performance)
    >
    > 2. Monitor the progress of the operation?
    > (Overall percentage complete would be great, but even seeing something
    > like "23 of 84 sessions complete" would be helpful.)
    >
    >
    > start cmd.exe /c robocopy \\server1\$drivename\sharename\sharename1
    > drivename\sharename\sharename1 <lots of robocopy parameters go here>
    > start cmd.exe /c robocopy \\server1\$drivename\sharename\sharename2
    > drivename\sharename\sharename2 <lots of robocopy parameters go here>
    > etc...........
    > etc...........

      My System SpecsSystem Spec

  3. #3


    Mark D. MacLachlan Guest

    Re: Can Powershell help me automate this?

    Gary wrote:

    > I routinely copy a lot of files between different servers via
    > robocopy, and I was wondering if there is a better way to create and
    > monitor the copy jobs. What I currently do is manually create a
    > batch file (see example below), and then run it in the console
    > session of the server via RDP. This lets me logon periodically and
    > check how the copies are going. (We're talking an average of 50-100
    > CMD windows and terabytes of files, so it takes quite a while)
    >
    > Is there an easy way to:
    >
    > 1. Automate building the batch file or creating an equivalent?
    > (The robocopy needs to run from the destination server, in a
    > session that is not affected by anyone logging onto the server, and
    > there can be more than 100 shares that need to be copied, but I try
    > to limit the number of concurrent sessions to 100 or less for
    > performance)
    >
    > 2. Monitor the progress of the operation?
    > (Overall percentage complete would be great, but even seeing
    > something like "23 of 84 sessions complete" would be helpful.)
    >
    >
    > start cmd.exe /c robocopy \\server1\$drivename\sharename\sharename1
    > drivename\sharename\sharename1 <lots of robocopy parameters go here>
    > start cmd.exe /c robocopy \\server1\$drivename\sharename\sharename2
    > drivename\sharename\sharename2 <lots of robocopy parameters go here>
    > etc...........
    > etc...........
    Your not providing enough information about the need to really offer
    and sound scripting advice. Are the shares changing all the time that
    you need to keep creating the batch files?

    I'm still ramping up on PowerShell. Were I to do this in VBScript I
    would add all the commands into an array and loop through that array.
    That would give you an index number that could be used for your
    reporting of status.

    Hope that helps,

    Mark D. MacLachlan


    --


      My System SpecsSystem Spec

Can Powershell help me automate this? problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: automate network diagnostics with Powershell? Marco Shaw [MVP] PowerShell 0 19 Feb 2009
automate FTP pete0085 VB Script 1 26 Dec 2008
how to automate ftp using powershell? Jeffery Jensen PowerShell 4 10 Mar 2008
ANN: FinalBuilder action to automate PowerShell Peter Thornqvist PowerShell 0 08 Nov 2006
Using PowerShell to automate FTP transfers =?Utf-8?B?RGF2aWRUTQ==?= PowerShell 15 28 Sep 2006