#----------------------------------------------## Validate manager exists#----------------------------------------------#Start-Sleep-s1$Manager=Get-ADUser$tbManager.Text
# If the manager exists in AD then write a confirmation message to the rick text boxIf($Manager|where-object{$_.SamAccountName-eq$tbManager.Text}){$rtbInformation.SelectionColor='green'$rtbInformation.AppendText("Validation check for manager has passed.`r")$rtbInformation.AppendText("`n")}# If the manager is not found then write a failure message and break the scriptElse
{$rtbInformation.SelectionColor='red'$rtbInformation.AppendText("ERROR: The manager does not exist, please check and run creation again.")$rtbInformation.AppendText("`n")start-sleep-Seconds2enablebuttons
Return
}
if(Get-ADUser-Identity$tbUsername.text|Where-Object{$_.SamAccountName-eq$tbUsername.Text}){$richtextbox1.SelectionColor='Green'$richtextbox1.AppendText("User created successfully")$richtextbox1.AppendText("`n")}Else
{$richtextbox1.SelectionColor='Red'$richtextbox1.AppendText("User not created")$richtextbox1.AppendText("`n")}