Need Help with Look

Welcome Forums General PowerShell Q&A Need Help with Look

This topic contains 3 replies, has 4 voices, and was last updated by

 
Participant
2 years, 3 months ago.

  • Author
    Posts
  • #53360

    Participant
    Points: 0
    Rank: Member

    Hey All,

    This is probably a simple issue that can be fixed quickly but I need another repair of eyes. Below is my code. I'm trying to keep this menu in a loop until the user is finished. I set a simple if-else statement to ask the user if they are finished and it should end loop and continue. Instead, it's kept in endless loop, I'm sure there is something missing. I'm open to other methods of achieving this but would like if someone can help repair this path.

    Do {
    Write-host "1. Brokers"
    Write-host "2. Capital Advisory"
    Write-host "3. Interns"
    Write-host "4. Retail Leasing"
    Write-host "5. Accounting"
    Write-host "6. Analysts- Full"
    Write-host "7. Analyst File Access"
    write-host "8. Assistants"
    write-host "9. ern"
    Write-host "10. Quit and exit"
    [Int]$xMenuChoiceA = read-host "Please Choose File Access Groups for User 1-10.."
    Switch( $xMenuChoiceA ){
    1{get-brokers}
    2{set-ca}
    3{add-intern}
    4{add-retaillease}
    5{set-accounting}
    6{add-analystfull}
    7{add-analsystfile}
    8{set-assistants}
    9{remove-ern}
    default{}
    }

    $continue=read-host "Another Group Needed? Y or N"
    if ($continue -eq "Y"){
    $continue=$true
    }
    else{
    $continue=$false
    }

    } while ($continue=$true)

  • #53364

    Participant
    Points: 0
    Rank: Member

    The comparison is -eq not =, but since it's a Boolean already just

    While ($continue)

    Will work.

  • #53366

    Moderator
    Points: 24
    Team Member
    Rank: Member

    Your while statement is incorrect. You're assigning $true as a value to $continue not testing for $true.

    } while ($continue=$true)

    Change it to below and it will work.

    } while ($continue)

    or

    } while ($continue -eq $true)

  • #53415

    Participant
    Points: 21
    Rank: Member

    Note:

    $here = @"

    1. Brokers
    2. Capital Advisory
    3. Interns
    4. Retail Leasing
    5. Accounting
    6. Analysts- Full
    7. Analyst File Access
    8. Assistants
    9. ern
    10. Quit and exit

    "@

    $here

The topic ‘Need Help with Look’ is closed to new replies.