Solved

Powershell Error: missing statement body in for loop

Posted on 2013-06-07
2
800 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 84

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

856 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