is there a particular reason you want to use II? And I'm not completely clear 
about your quoting requirements, but I'd do something like this:

$arrayPaths = "Dir/1", "Dir/2", "Dir/3" -- don't need the initializer since you 
have the comma operator
$options = '--verbose --recursive --blah --chmod=D=rwx,F=rw'

foreach ($path in $arrayPaths)
{
        $source = "/cygdrive/c/Top Level/$path"
        $dest = "10.0.0.13::test" + '"' + "/Top Level/$path + '"'
        cmd.exe /c c:\Program Files\cwRsync\rsync.exe $options "$source" "$dest"
}

Using "cmd /c" has the distinct advantage of properly setting $LastExitCode for 
error checking, which II often does not.

-----Original Message-----
From: Joseph L. Casale [mailto:jcas...@activenetwerx.com] 
Sent: Thursday, January 14, 2010 3:45 PM
To: NT System Admin Issues
Subject: Powershell Question

Guys,
I have a backup script to have ready for implementation on Saturday morning. It 
uses rsync to copy on diffs to a remote Linux server over a vpn through a slow 
link. I finally finished all the server and vpn setup and I had been avoiding 
how to handle the huge dataset, which would make a simple dos script of 
rsyncing the whole tree at once nearly impossible.

What I plan to do is iterate over a few known paths (and possibly add in some 
error handling later). Does this make sense (highly abbreviated):

$arrayPaths = @("Dir 1/", "Dir 2/", "Dir 3/")
$Options = '--verbose --recursive --blah --chmod=D=rwx,F=rw'

foreach ($i in $arrayPaths)
{Invoke-Item C:\Program Files\cwRsync\rsync.exe $Options `"/cygdrive/c/Top 
Level/$i`" 10.0.0.13::test`"/Top Level/$i`"}

So what's the most elegant way to make the ii command run this mess?

Thanks!
jlc


~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~


~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

Reply via email to