Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Powershell question


  • Please log in to reply
5 replies to this topic

#1 vesterlee2008

vesterlee2008

  • Members
  • 9 posts
  • OFFLINE
  •  
  • Local time:01:30 PM

Posted 23 April 2017 - 04:21 PM

When I load this command I get the error at the bottom.   

PS C:\WINDOWS\system32> $intFolders = 10
$intPad
$i = 1
New-Variable -Name strPrefix -Value "testFolder" -Option constant
do {
if ($i -lt 10)
{$intPad=0
New-Item -Path C:\mytempFolder -Name $strPrefix$intPad$i -Type directory}

 

 

I get this error message when I load this command above. please help   I ma really new to all this

Missing statement block after 'else' keyword.
+ CategoryInfo : ParserError: ( :) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingStatementBlockAfterElse


Edited by hamluis, 23 April 2017 - 04:44 PM.
Moved from Web Browsing/Email to Programming - Hamluis.


BC AdBot (Login to Remove)

 


#2 hamluis

hamluis

    Moderator


  • Moderator
  • 56,379 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Killeen, TX
  • Local time:02:30 PM

Posted 23 April 2017 - 04:32 PM

Worth a look:  https://www.google.com/#q=parentcontainserrorrecordexception+powershell .

 

Louis


Edited by hamluis, 23 April 2017 - 04:41 PM.


#3 britechguy

britechguy

    Been there, done that, got the T-shirt


  • Moderator
  • 9,237 posts
  • ONLINE
  •  
  • Gender:Male
  • Location:Staunton, VA
  • Local time:03:30 PM

Posted 23 April 2017 - 04:34 PM

Well, for starters you have an opening curly brace for the do without a corresponding close.  There is no until or while condition for the do.

 

I think this is throwing off your if syntax.


Brian  AKA  Bri the Tech Guy (website in my user profile) - Windows 10 Home, 64-Bit, Version 1809, Build 17763 

     Presenting the willfully ignorant with facts is the very definition of casting pearls before swine.

             ~ Brian Vogel

 

 

 

              

 


#4 vesterlee2008

vesterlee2008
  • Topic Starter

  • Members
  • 9 posts
  • OFFLINE
  •  
  • Local time:01:30 PM

Posted 23 April 2017 - 05:12 PM

here is what I ran and this is not working at all either

 

Ok  I ran it and got another RED message

 

$intFolders = 10
$i         = 1
New-Variable -Name strPrefix -Value "testFolder" -Option constant

do{
    if($i -lt 10){
        $intPad = 0
        New-Item -Path C:\mytempFolder -Name $strPrefix$intPad$i -Type directory
    }else{
    New-Item -Path c:\mytempfolder -Name $strPrefix$i -Type directory
    }
    {Until ($i -eq $intFolders+1)



#5 britechguy

britechguy

    Been there, done that, got the T-shirt


  • Moderator
  • 9,237 posts
  • ONLINE
  •  
  • Gender:Male
  • Location:Staunton, VA
  • Local time:03:30 PM

Posted 23 April 2017 - 05:20 PM

Well, now you have a '{' in front of your "Until" which should be a '}'.

 

Also, you have no increment on $i


Edited by britechguy, 23 April 2017 - 05:21 PM.

Brian  AKA  Bri the Tech Guy (website in my user profile) - Windows 10 Home, 64-Bit, Version 1809, Build 17763 

     Presenting the willfully ignorant with facts is the very definition of casting pearls before swine.

             ~ Brian Vogel

 

 

 

              

 


#6 vesterlee2008

vesterlee2008
  • Topic Starter

  • Members
  • 9 posts
  • OFFLINE
  •  
  • Local time:01:30 PM

Posted 23 April 2017 - 07:19 PM

Thanks for the help,   I have it fixed now






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users