numberone.ps1<\/a> (917 Bytes)<\/p>","upvoteCount":8,"datePublished":"2013-08-05T19:08:38.000Z","url":"https://community.spiceworks.com/t/can-anyone-tell-me-what-i-am-doing-wrong-here/230421/1","author":{"@type":"Person","name":"michaelnorton9870","url":"https://community.spiceworks.com/u/michaelnorton9870"}},{"@type":"Answer","text":"Try posting in the programming group <\/p>","upvoteCount":0,"datePublished":"2013-08-05T19:16:36.000Z","url":"https://community.spiceworks.com/t/can-anyone-tell-me-what-i-am-doing-wrong-here/230421/2","author":{"@type":"Person","name":"r0b","url":"https://community.spiceworks.com/u/r0b"}},{"@type":"Answer","text":"
What’s the error?<\/p>","upvoteCount":0,"datePublished":"2013-08-05T19:17:39.000Z","url":"https://community.spiceworks.com/t/can-anyone-tell-me-what-i-am-doing-wrong-here/230421/3","author":{"@type":"Person","name":"Rob-Dunn","url":"https://community.spiceworks.com/u/Rob-Dunn"}},{"@type":"Answer","text":"
thats just it rob. it doesn’t detect an error. all it does is skip the two lines of code as if they didn’t exist and move on with the rest of the program. but the error i see is that it can’t detect the two lines of code i have written exactly as two previous lines of code that WERE detected.<\/p>","upvoteCount":0,"datePublished":"2013-08-05T19:23:14.000Z","url":"https://community.spiceworks.com/t/can-anyone-tell-me-what-i-am-doing-wrong-here/230421/4","author":{"@type":"Person","name":"michaelnorton9870","url":"https://community.spiceworks.com/u/michaelnorton9870"}},{"@type":"Answer","text":"
sorry i didn’t know where to post it. i just joined this site like a half an hour ago. have no clue how to navigate it yet.<\/p>","upvoteCount":0,"datePublished":"2013-08-05T19:24:11.000Z","url":"https://community.spiceworks.com/t/can-anyone-tell-me-what-i-am-doing-wrong-here/230421/5","author":{"@type":"Person","name":"michaelnorton9870","url":"https://community.spiceworks.com/u/michaelnorton9870"}},{"@type":"Answer","text":"
got this error after entering banana who?<\/p>\n
At line:51 char:21\n+ Start Sleep -Seconds <<<< 3\n + CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingExc \n eption\n + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.Star \n tProcessCommand\n\n<\/code><\/pre>\nOrange you going to tell us what code is skipped?<\/p>","upvoteCount":3,"datePublished":"2013-08-05T19:24:46.000Z","url":"https://community.spiceworks.com/t/can-anyone-tell-me-what-i-am-doing-wrong-here/230421/6","author":{"@type":"Person","name":"Paul_Maxim","url":"https://community.spiceworks.com/u/Paul_Maxim"}},{"@type":"Answer","text":"
The second to last line should be ‘Start-Sleep -seconds 5’.<\/p>\n
Notice the dash between Start and Sleep.<\/p>\n
Also, there is a PowerShell group and a button for pasting code!<\/p>","upvoteCount":0,"datePublished":"2013-08-05T19:33:55.000Z","url":"https://community.spiceworks.com/t/can-anyone-tell-me-what-i-am-doing-wrong-here/230421/7","author":{"@type":"Person","name":"anthony","url":"https://community.spiceworks.com/u/anthony"}},{"@type":"Answer","text":"
And you’ll also you’ll want to throw in this line:<\/p>\n
$userReply = $null\n<\/code><\/pre>\nRight before the part it skips because $userReply already equals \"who’s there’ so it will skip that section.<\/p>","upvoteCount":0,"datePublished":"2013-08-05T19:35:59.000Z","url":"https://community.spiceworks.com/t/can-anyone-tell-me-what-i-am-doing-wrong-here/230421/8","author":{"@type":"Person","name":"anthony","url":"https://community.spiceworks.com/u/anthony"}},{"@type":"Answer","text":"
thats weird i didn’t get that same error. when it runs the lines<\/p>\n
Clear-Host \nWrite output “POWERSHELL oranges!!!”<\/p>\n
Start-Sleep -Seconds 5<\/p>\n
Clear-Host<\/p>\n
then skips the lines<\/p>\n
while ($userReply -ne “who’s there?”){ \n$userReply = read-host “knock knock” \n}<\/p>\n
then runs the rest of the program just fine picking up at<\/p>\n
Clear-host \nwhile ($userReply -ne “banana who?”){ \n$userReply = read-host “banana” \n}<\/p>\n
i have the lines it skips marked in the original post paul, they are marked with “<—”<\/p>","upvoteCount":0,"datePublished":"2013-08-05T19:47:02.000Z","url":"https://community.spiceworks.com/t/can-anyone-tell-me-what-i-am-doing-wrong-here/230421/10","author":{"@type":"Person","name":"michaelnorton9870","url":"https://community.spiceworks.com/u/michaelnorton9870"}},{"@type":"Answer","text":"
I ran Twon’s script and it worked perfectly. I suspect it’s running find, but you’re clearing the screen and never seeing the results on screen. Get rid of all of the Clear-Host cmdlet’s and try again.<\/p>","upvoteCount":0,"datePublished":"2013-08-05T21:42:03.000Z","url":"https://community.spiceworks.com/t/can-anyone-tell-me-what-i-am-doing-wrong-here/230421/11","author":{"@type":"Person","name":"martin9700","url":"https://community.spiceworks.com/u/martin9700"}},{"@type":"Answer","text":"
I forget exactly how Idera works, but set a breakpoint on the first line, then “Step Into” each line of code. First hit F5 which will run the script to the breakpoint (which is line one), then hit F11 to step through each line of code and you can see what’s happening interactively.<\/p>","upvoteCount":0,"datePublished":"2013-08-05T21:43:21.000Z","url":"https://community.spiceworks.com/t/can-anyone-tell-me-what-i-am-doing-wrong-here/230421/12","author":{"@type":"Person","name":"martin9700","url":"https://community.spiceworks.com/u/martin9700"}}]}}
so i am very new to scripting. as in this is my first script ever. i am using a program called idera powershell advanced (or something like that) and i am trying to figure this whole scripting thing out. so i was writing my first script and i was supre happy because it was working smothely… right up until it just skipped two lines of my code like they didn’t even exist. other than that the script runs fine. i just wanna figure this out and get a fully functional script runing before i move on to the next one in my book(powershell2.0) here is my code
$userReply = “”
while ( $userReply -ne “who’s there?”){
$userReply = read-host “knock knock!”
}
Clear-Host
while ($userReply -ne “orange who?”){
$userReply = read-host “orange.”
}
Clear-host
Write-output “orange you glad you created this powershell script?”
Start-Sleep -Seconds 5
Clear-Host
while ($userReply -ne “who’s there?”){
$userReply = read-host “knock knock”
}
Clear-Host
Write output “POWERSHELL oranges!!!”
Start-Sleep -Seconds 5
Clear-Host
while ($userReply -ne “who’s there?”){ <–it skips this line
$userReply = read-host “knock knock” <–and this line
}
Clear-host
while ($userReply -ne “banana who?”){
$userReply = read-host “banana” <---- but then it picks back up here like nothing is wrong
}
Clear-Host
Write output “orange you glad i didn’t say orange?!”
Start-sleep -Seconds 5
Write output “the knock knock joke”
Write output “”
Write output “Copyright 2006 - jerry lee ford, jr.”
Start Sleep -Seconds 5
Clear Host
i am also attatching a .ps1 file containing the script. if anyone can help me i would love you forever and always.
numberone.ps1 (917 Bytes)
8 Spice ups
r0b
(JustRob)
August 5, 2013, 7:16pm
2
Try posting in the programming group
Rob-Dunn
(Rob Dunn)
August 5, 2013, 7:17pm
3
thats just it rob. it doesn’t detect an error. all it does is skip the two lines of code as if they didn’t exist and move on with the rest of the program. but the error i see is that it can’t detect the two lines of code i have written exactly as two previous lines of code that WERE detected.
sorry i didn’t know where to post it. i just joined this site like a half an hour ago. have no clue how to navigate it yet.
got this error after entering banana who?
At line:51 char:21
+ Start Sleep -Seconds <<<< 3
+ CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingExc
eption
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.Star
tProcessCommand
Orange you going to tell us what code is skipped?
3 Spice ups
anthony
(Twon of An)
August 5, 2013, 7:33pm
7
The second to last line should be ‘Start-Sleep -seconds 5’.
Notice the dash between Start and Sleep.
Also, there is a PowerShell group and a button for pasting code!
anthony
(Twon of An)
August 5, 2013, 7:35pm
8
And you’ll also you’ll want to throw in this line:
$userReply = $null
Right before the part it skips because $userReply already equals "who’s there’ so it will skip that section.
anthony
(Twon of An)
August 5, 2013, 7:38pm
9
Whole script should look like:
$userReply = $null
while($userReply -ne "who's there?")
{
$userReply = read-host "knock knock!"
}
Clear-Host
while($userReply -ne "orange who?")
{
$userReply = read-host "orange."
}
Clear-host
Write-output "orange you glad you created this powershell script?"
Start-Sleep -Seconds 5
Clear-Host
while($userReply -ne "who's there?")
{
$userReply = read-host "knock knock"
}
$userReply = $null
Clear-Host
Write-output "POWERSHELL oranges!!!!!"
Start-Sleep -Seconds 5
Clear-Host
while($userReply -ne "who's there?")
{
$userReply = read-host "knock knock"
}
Clear-host
while($userReply -ne "banana who?")
{
$userReply = read-host "banana"
}
Clear-Host
Write-output "orange you glad i didn't say orange?!"
Start-sleep -Seconds 5
Write-output "the knock knock joke"
Write-output ""
Write-output "Copyright 2006 - jerry lee ford, jr."
Start-Sleep -Seconds 5
Clear-Host
thats weird i didn’t get that same error. when it runs the lines
Clear-Host
Write output “POWERSHELL oranges!!!”
Start-Sleep -Seconds 5
Clear-Host
then skips the lines
while ($userReply -ne “who’s there?”){
$userReply = read-host “knock knock”
}
then runs the rest of the program just fine picking up at
Clear-host
while ($userReply -ne “banana who?”){
$userReply = read-host “banana”
}
i have the lines it skips marked in the original post paul, they are marked with “<—”
I ran Twon’s script and it worked perfectly. I suspect it’s running find, but you’re clearing the screen and never seeing the results on screen. Get rid of all of the Clear-Host cmdlet’s and try again.
I forget exactly how Idera works, but set a breakpoint on the first line, then “Step Into” each line of code. First hit F5 which will run the script to the breakpoint (which is line one), then hit F11 to step through each line of code and you can see what’s happening interactively.