Problems with script in powershell

I’m trying to do a script using the “while” command with two conditions, the second condition is to stop the script when I type “end”. I cannot do it.

$semester = Read-Host -Prompt ‘Input Semester Name’
md $semester
Set-Location $semester
while(($courseID = Read-Host -Prompt ‘Input Course Name, type end when finished’) $courseID -ne
"end"{
md $courseID
cd $courseID
md “Assignments”
md “Notes”
cd ..
}
endwhile
cd ..
tree $semester
Write-Host “All Done, See you next semester”

Thank you

Raul,
Welcome to the forum. :wave:t4:

Please do not use aliasses in scripts. They make your code much harder to read.

Thanks in advance.

You can create a folder along with its subfolders at once. You do not have to create it step by step.

$semester = Read-Host -Prompt 'Input Semester Name'
$courseID = Read-Host -Prompt "Input Course Name, type 'end' when finished"
while ($courseID -ne "end") {
    New-Item -Name "$semester\$courseID\Assignments" -ItemType Directory | Out-Null
    New-Item -Name "$semester\$courseID\Notes" -ItemType Directory | Out-Null
    $courseID = Read-Host -Prompt "Input Course Name, type 'end' when finished"
}