Explain each line of this script: #Set up password
$NewPassword = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile
$NewPassword.Password = "Blacksun565731"
$NewPassword.ForceChangePasswordNextLogin = $False

#Set parameters
$first_name = read-host -Prompt "Input new starter First Name"
$surname = read-host -Prompt "Input new starter Last Name"
$displayName = $first_name + " " + $surname
$firstChar = $first_name.substring(0,1)
$BSGusername = $firstChar + $surname
$BSG_email = $BSGusername + "@blacksun-global.com"
$Department = read-host -Prompt "Input new starters Department"
$title = read-host -Prompt "Input new starters Job Title"

#Setup the account
New-AzureADUser -UserPrincipalName $BSG_email -DisplayName $displayName -PasswordProfile $NewPassword -AccountEnabled $True -MailNickName $BSGusername -City "London" -CompanyName "Black Sun Global" -Country "United Kingdom"

#Set Usage Location
Set-AzureADUser -objectid $BSG_email -UsageLocation "GB"

#Set SPB License Plan
$LicPlan="SPE_E3,MCOEV,MCOPSTN1"
$License = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicense
$License.SkuId = (Get-AzureADSubscribedSku | Where-Object -Property SkuPartNumber -Value $LicPlan -eq).SkuID
$assignlic = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses
$assignlic.AddLicenses = $License
Set-AzureADUserLicense -ObjectId $BSG_email -AssignedLicenses $assignlic
Get-AzureADUserLicenseDetail -objectid $BSG_email

Set-Mailbox -Identity $BSG_email -EmailAddresse @{add="$<PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>"}
Set-Mailbox -Identity $BSG_email -EmailAddresse @{add="$<PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>"}

#Get's the first avaible Teams number
$number = get-CsPhoneNumberAssignment -IsoCountryCode GB -PstnAssignmentStatus Unassigned | select -First 1 | select TelephoneNumber
$number = $number -replace '[TelephoneNumber@{=+}]'
#Assigns the number
Set-CsPhoneNumberAssignment -Identity $BSG_email -PhoneNumber $number -PhoneNumberType CallingPlan

<# Email is in testing pahse only seems to work for @blacksunplc.com domain
#-------------------------------EMAIL------------------------------#

$admusername = read-host -Prompt "Input your LOCAL ADM Username"
$admpassword = Read-Host "Enter LOCAL ADM password" -AsSecureString

$From = "itassets@blacksunplc.com"
$To = "itassets@blacksunplc.com"
$BCC = "svalchev@blacksunplc.com"
$Subject = "New Starter Details: $displayName"
$Body = "Hi,<br>
    
   The IT details for $displayname have been created. They have been assigned permissions based on their role and you can now email them the content required for their start:<br>

    
   <br>Username: $BSGusername
    
   <br>Password: Blacksun565731

   <br>Email: $BSG_email

   <br>Many thanks,
    
   <br>IT Support
    <br>
    <br>This email was generated automatically. Please contact <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS> if any details are incorrect"
    
 
# Define the SMTP server details
$SMTPServer = "smtp.blacksunplc.com"
$SMTPUsername = $admusername
$SMTPPassword = $admpassword
 
# Create a new email object
$Email = New-Object System.Net.Mail.MailMessage
$Email.From = $From
$Email.To.Add($To)
$Email.Bcc.Add($BCC)
$Email.Subject = $Subject
$Email.Body = $Body
# Uncomment below to send HTML formatted email
$Email.IsBodyHTML = $true
 
# Create an SMTP client object and send the email
$SMTPClient = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort)
 
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($SMTPUsername, $SMTPPassword)
$SMTPClient.Send($Email)
#>