Tag Archives: email

Automatically Assign Licences to New Office 365 Accounts

Here’s the scenario: Users are created in Active Directory, on-premise.  The AD Sync Service then will sync up the user account to Office 365.  However, a license is not assigned.  The rule of thumb when assigning new licenses is that people in the call center get an E1 license and the rest of the employees get an E3 license.  The identifying characteristic for the call center users is that their email address is <someone>@mycallcenter.com and everyone else has a different domain for their email.  For your use case, you may have other specific identifiers to help determine the appropriate license.  If one size fits all, you can eliminate the the lines to change to an E1 license and leave the default.

I chose to use a security group to identify users that need a license assigned.  In this case it’s “ADGroup-UsersNeedingLicenses”  When the script runs it will iterate through all members of that security group  and check to see if the account has synchronized up with Office 365.  If the account is there, it will evaluate which license to assign and then assign it.  It will then get the user’s licenses from Office 365 and display them so you can validate that it was updated.  It then removes the user from the security group and we’re done.

If you like, you can set this on a scheduled task to automatically assign licenses to new users on an interval.  One would need to store credentials in a file in order for it to be automated.  I like it because it’s one less administrative task I need to deal with.  I can create the account in AD then go take care of other things.  I come back after a bit and then the user is synchronized and licensed.

<# Get credentials to connect to Office 365 using PowerShell#>
$Password = Get-Content j:\myscripts\ADCredentials.txt | ConvertTo-SecureString
$credential = New-Object System.Management.Automation.PsCredential("ServiceAccount@company.onmicrosoft.com",$password)

<# Connect to MSOL #>
Connect-MsolService -Credential $credential

<# Get AD Users designated for license assignment #>
$usersNeedingLicense = Get-ADGroupMember -Identity ADGroup-UsersNeedingLicenses

<# Iterate through the collection of AD users designated for license assignment #>
ForEach ($ADUser in $usersNeedingLicense){
 $ADUser = Get-ADUser -Identity $ADUser -Properties *
 "AD UPN: " + $ADUser.UserPrincipalName
 Try {
 $o365User = Get-MsolUser -UserPrincipalName $ADUser.UserPrincipalName -ErrorAction Stop
 $licenseType = "mycompany:ENTERPRISEPACK" <# set default to E3 #>
 If ( $ADUser.UserPrincipalName.Contains("@mycallcenter.com")){$licenseType="mycompany:STANDARDPACK"} <# Assign E1 #>

 "Assign: $licenseType"
 <# Locate and assign license using matching UPN #>
 Set-MsolUser -UserPrincipalName $ADUser.UserPrincipalName -UsageLocation "US" <# Set user licensing to Unites States #>
 Set-MsolUserLicense -UserPrincipalName $ADUser.UserPrincipalName -AddLicenses $licenseType
 <# view for validation #>
 Get-MsolUser -UserPrincipalName $ADUser.UserPrincipalName | fl UserPrincipalName, Licenses
 <# Remove AD user from ADGroup-UsersNeedingLicenses #>
 Remove-ADGroupMember -Identity ADGroup-UsersNeedingLicenses -Members $ADUser.SamAccountName -Confirm:$false

 Catch [System.Exception]{
 $ADUser.UserPrincipalName + " is not in Office 365 yet."
 Finally {$error.Clear() }

Office 365 – Shared Mailbox – Sent email not saving in shared “Sent Items”

Shared mailboxes migrated just fine into Office 365 (Exchange Online) shared mailboxes.  Users that are able to send email on behalf of the shared mailbox are having the sent email copy stored in the “Sent Items” of the sender as opposed to the “Sent Items” of the shared mailbox.  All the people who share use of the shared mailbox would like to be able to see sent email by others using the  shared mailbox.

Microsoft decided that this should be an ability of Exchange Online, but did not set that behavior by default. Please refer to this TechNet article for more details on how to set this behavior.

I needed a script that would be able to march through all the shared mailboxes and make the change.  Here’s the script:

$sharedMailboxCollection = Get-Mailbox -Filter {RecipientTypeDetails -eq 'SharedMailbox'}
foreach ($mailBox in $sharedMailboxCollection)
 set-mailbox $mailBox.UserPrincipalName -MessageCopyForSentAsEnabled $True
 set-mailbox $mailBox.UserPrincipalName -MessageCopyForSendOnBehalfEnabled $True

E-mail Monitoring in ServiceDesk

Admin>Data>Application Properties


Reply-to address in the Outbound Mail Settings contains email address from which ServiceDesk sends notifications email.  This should match the email address used in the Inbound Mail Settings to ensure email responded to goes to the inbox being monitored.

If an incoming email subject contains “New Incident” or “New Ticket”, an incident will automatically be created for that email.  From will be used for the Primary Contact and the body will be used for the description.  File attachments are saved with the ticket and added to document management.

Replies are handled by this process.  System generated email footers contain a reply code to identify associated tickets.

If email cannot be identified, a task will be created for Service Manager to classify email.

SD.Email.InboundManagement: This workflow looks at incoming e-mail to ServiceDesk that have an improper subject line and create tasks for Service Managers to determine if they should become incidents.  It is called by SD.EmailMonitor when an email with the incorrect subjet is received.

SD.Email.Monitor: This Monitoring project monitors the inbox(es) configured to receive ServiceDesk incidents via email. It reads and evaluates email, checking for valid email address format, and whether the email is a response.  It creates tickets for Incidents deemed valid or updates a ticket if it is a response.

SD.EmailServices: This project contains the email templates that define the content of email in ServiceDesk.

Sending E-mail in ServiceDesk

Instead of using the Send E-mail component, invoke the using the SD.EmailSerives project.  This way, you have a central location for managing email in ServiceDesk, consistency in format and behavior.  An example of how to invoke this can be found in Change Management.

Primay model creates, submodels deliver (email templates).  ReportID is required to get the process history, so it cannot be null.

Disabling/Enabling Incident notifications for SendNotificationIncidentCreation and SendNotificationInicdentResolution:
Admin>Data>Application Properties