Powershell insert sleep command into Powershell foreach script.

Please refer to the following code.  In the first line of code, I want to insert a start-sleep command between the get-ftp statement and the foreach-object -process statement.  The idea is to obtain a list of files, but delay the processing for 180 seconds.

How is this completed?

get-ftp -server myserver -user myuser -password mypassword -ssh -force -path /path/to/data/*.csv | foreach-object -process {
get-ftp -server myserver -user myuser -password mypassword -ssh -force -path "/path/to/data/" -remotefile ($_.Filename) -localfile ("C:\path\to\data\" + $_.Filename) 
send-ftp -server myserver -user myuser -password mypassword -ssh -force -path "/path/to/data/" -remotefile ($_.Filename) -rename ("/path/to/data/" + $_.Filename)

Open in new window

jloomansAsked:
Who is Participating?
 
BSonPoshConnect With a Mentor Commented:
oh... try this

get-ftp -server myserver -user myuser -password mypassword -ssh -force -path /path/to/data/*.csv | foreach-object -begin {start-sleep 180} -process {

0
 
BSonPoshCommented:
start-sleep 180
0
 
jloomansAuthor Commented:
How is this nested into the first line of code, so I can obtain the list of files to process, sleep 180, then start the processing?
0
 
jloomansAuthor Commented:
Ahh, so simple.  I should've known that.
0
 
BSonPoshCommented:
np
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.