Need Help With PS Form

I have created the attached form ( First Time) Now I need your help to complete this script.

Click Ok to close the form.— Need help ( after input required fields, form closed and continue the script and show messages on screen)

        1. Connect to SFB shell 

        2. Create the sfb Online User
     
        3.  Command to sync the user 
         
        4.  wait 30min

        5. Verify the user has created ---> Need a help 
               
        6. if only  ----> Need a help

       7. Connect to MS Teams 
   
       8. execute the command.

        9. Write the message if no errors - Need a help
$Okbutton.Add_Click({
    # for demo just output in console
     Write-Host " Email:$($objTextBox.Text), PH:$($objTextBox2.Text), EXT:$($objTextBox3.Text),$Dialplan,$voiceroutingpolicy"
  
  #Activate voice calling and assign a number to the user
     Enable-CsUser -Identity $($objTextBox.Text) -SipAddressType Emailaddress -HostingProviderProxyFqdn 'sipfed.online.lync.com' -DomainController 'xxxxx'
   
  #Enterprise Voice users only 
    Set-CsUser -Identity sip:$($objTextBox.Text) -LineUri "tel:$($objTextBox2.Text);ext=$($objTextBox3.Text)" -DomainController 'xxxxxx'

   #Command to sync the user

    Invoke-command -ComputerName zzzzzzz -ScriptBlock { Start-AdSyncSyncCycle }
   
  # wait 30min

   Start-Sleep - 900
 
    # Connect to MS Teams 
    $File = "C:\Temp\Password.txt"
    $User = "aaaa@domain.com"
    $UserCredential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $User, (Get-Content $File | ConvertTo-SecureString)
 
   Import-Module MicrosoftTeams -RequiredVersion 2.3.1
   Connect-MicrosoftTeams -Credential $UserCredential

  #Veryfiy the user has created
      
   Get-CSOnlineUser -Identity $($objTextBox.Text)  | ft HostingProvider

  # If Only execuite 

   Get-CSOnlineUser -Identity $($objTextBox.Text) |Select-Object HostingProvider
   Grant-CsTeamsUpgradePolicy -Identity $($objTextBox.Text) -PolicyName 'UpgradeToTeams'
   Get-CsMeetingMigrationStatus -Identity $($objTextBox.Text) | ft LastMessage
 
   # *******************************
   # * Enterprise Voice users only *
   # *******************************
     
     Set-CsUser -Identity $($objTextBox.Text) -EnterpriseVoiceEnabled $true -HostedVoicemail $true -Verbose
     Grant-CsTenantDialPlan -Identity $($objTextBox.Text) -PolicyName $($listBox.SelectedItem) -Verbose
     Grant-CsOnlineVoiceRoutingPolicy -Identity $($objTextBox.Text) -PolicyName $($listBox1.SelectedItem) -Verbose
  
# Write the message if no errors
      Write-Host "Enterprise Voice Enabled"
       
     $objForm.Close()
}) 

Hi,

How do I edit this post? looks like the content is not clear.

How do I verify the user creation and continue to connect to MS Teams?