Solved

Powershell Error: missing statement body in for loop

Posted on 2013-06-07
2
739 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
2 Comments
 
LVL 82

Accepted Solution

by:
oBdA earned 500 total points
Comment Utility
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
Comment Utility
Opps thought it was a Powershell script the way the article read. Thanks.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
Synchronize a new Active Directory domain with an existing Office 365 tenant
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.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now