I am trying to write a script that will ask me if I want to create a NIC team. I'm trying to add some logic to it, so the only way to continue is to either answer "n" to the question or meet the condition. The below kinda works, but
if I meet the condition it will create the team but keeps asking me if I want to try again.
$askTeam = Read-Host "I can configure the NIC team for you. Plug a cable into the two nics you want to team before continuing.` Do you want me to create the NIC Team for you (Y/N)" if ($askTeam -eq "Y"){ Do { $Adapters = Get-NetAdapter | ?{$_.Status -eq "UP"} $NetAdapter = $Adapters.Name if ($NetAdapter.count -eq 2){ New-NetLbfoTeam -Name "Team #1" -TeamMembers ($NetAdapter[0],$NetAdapter[1]) -TeamingMode SwitchIndependent -LoadBalancingAlgorithm TransportPorts -Confirm:$false | Out-Null Set-NetLbfoTeamMember -Name $NetAdapter[0] -AdministrativeMode Standby | Out-Null }else{ $response = Read-Host "You must have exactly two NICs plugged in for me to successfully configure the NIC Team. Try again (Y/N)"} } While ($response -eq "y") }Thanks for your help