Solved

Powershell Error: missing statement body in for loop

Posted on 2013-06-07
2
871 Views
Last Modified: 2013-06-07
When running the follow script I get an error as follows, any suggestions:

At C:\Users\eroche\desktop\prod2testcopy.ps1:4 char:109
+ ... NewestFile=%%I)
+                    ~
Missing statement body in for loop.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : MissingLoopStatement


The Script:

SET DatabaseBackupPath=\\fpbackup\backup
echo.
echo Restore Database
FOR (/F "delims=|" %%I IN ('DIR "%DatabaseBackupPath%\sql\AOSProd_backup*.bak" /B /O:D') set NewestFile=%%I)
copy "%DatabaseBackupPath%\WebServer\%NewestFile%" "c:\"
0
Comment
Question by:FennerIT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 500 total points
ID: 39230141
That is not a Powershell script, it's a batch script. Save it as prod2testcopy.cmd and try again.
SET DatabaseBackupPath=\\fpbackup\backup
echo.
echo Restore Database
FOR /F "delims=" %%I IN ('DIR "%DatabaseBackupPath%\sql\AOSProd_backup*.bak" /B /O:D') set NewestFile=%%I
copy "%DatabaseBackupPath%\WebServer\%NewestFile%" "c:\"

Open in new window

0
 

Author Comment

by:FennerIT
ID: 39230218
Opps thought it was a Powershell script the way the article read. Thanks.
0

Featured Post

Ready to trade in that old firewall?

Whether you need to trade-up to a shiny new Firebox or just ready to upgrade from whatever appliance you're using now, WatchGuard has the right appliance for you! Find your perfect Firebox today with appliance sizing tool!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
Suggested Courses

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question