C
C
Crazy_Father2017-10-19 15:02:35
PowerShell
Crazy_Father, 2017-10-19 15:02:35

Power shell implementation of GO TO how?

Good afternoon, I'm writing a script on PS, stalled at the moment.
The user login is entered, the script requests this user login from AD, and it will be checked for existence, then it is reported whether there is such a login or not.
It is not very clear how to return to entering a new login if the login exists. There is no GO TO in Power Shell.
PS A piece of test code

cls

Import-Module activedirectory

Clear-Variable countUser

$tlogin = Read-Host "Введите логин пользователя"

$countUser = Get-ADUser -filter {SamAccountName -like $tlogin}

    if (!$countUser) {Write-Host "Пользователей не найдено"}
        else {Write-Host "Пользователь $tlogin найден, введите логин заново" } #Как отсюда вернуться на уровень ввода логина? $tlogin

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Satisfied IT, 2017-10-19
@Crazy_Father

It's not there anymore, use the While example (The while statement, or while loop, repeats lines of code as long as a certain condition is true)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question