Solved

Powershell logic

Posted on 2014-10-30
1
100 Views
Last Modified: 2014-10-30
Need to make sure I'm thinking this through.

If a criteria is true, then I need to perform another test, otherwise perform the default test.
Thus, I need to drop out of an if statement, but continue my foreach....is break the statement I need for this?

foreach ($cog in $widgests) {
if ($something -eq $true) {
  if ($something else -eq $true) {
    #do something
  } else {
    #This is bad - don't even try the additional tests
    break; #??
  }
} else {
  if ($test -eq $true) {write-host 'All is right with the world'} else {write-host 'Who moved my cheese?'}
}
}

Open in new window

0
Comment
Question by:sirbounty
[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
1 Comment
 
LVL 11

Accepted Solution

by:
Joe Klimis earned 500 total points
ID: 40413580
Hi

Change line 7 to Continue
This will just skip the loop itteration

break will end the foreach loop

I hope this helps

see here for a good explanation

Joe
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Synchronize a new Active Directory domain with an existing Office 365 tenant
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

751 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