Monthly Archives: October 2012

Get Office 365 Last Login Stats

$objUsers = get-mailbox -ResultSize Unlimited | select UserPrincipalName

#Iterate through all users

foreach ($objUser in $objUsers)


#Connect to the users mailbox
$objUserMailbox = get-mailboxstatistics -Identity $($objUser.UserPrincipalName) | Select LastLogonTime

#Prepare UserPrincipalName variable
$strUserPrincipalName = $objUser.UserPrincipalName

#Check if they have a last logon time. Users who have never logged in do not have this property
if ($objUserMailbox.LastLogonTime -eq $null)
#Never logged in, update Last Logon Variable
$strLastLogonTime = “Never Logged In”
}   else   {
#Update last logon variable with data from Office 365
$strLastLogonTime = $objUserMailbox.LastLogonTime


#Output result to screen for debugging
Write-host “$strUserPrincipalName : $strLastLogonTime”


Using ADSIEdit to change e-mail aliases on Office 365

  • Go to Start > Run and type adsiedit.msc
  • Now, find the unit where your AD user’s reside
  • Right click the user you want to edit and click Properties.
  • Find the variable proxyAddresses – this is the one you want to edit. When you add new e-mail aliases, you want to make sure that your primary e-mail address will start with upper-case SMTP. Your aliases, aka, secondary addresses should be lower-case smtp.

Setting Calendar permission Exchange 2010

To set the sharing permission for you, please refer the steps below,

1), connect to Exchange Online through PowerShell as administrator.

2), run Get-Mailbox to get the mailboxes you want to modify, you can use different filter to pick the user you want to configure, for example, Get-Mailbox -RecipientTypeDetails UserMailbox will return all user mailboxes(no shared mailboxes, room mailboxes and discovery mailbox). For detailed information, you can run Get-Help Get-Mailbox -Detailed | More.

3), prepare a text file, save the following content in 4 lines, you can customize the first line to the filter you want to set,

foreach($user in (Get-Mailbox -RecipientTypeDetails UserMailbox)) {

$cal = $user.alias+”:Calendar”

Add-MailboxFolderPermission -Identity $cal -User -AccessRights Reviewer


4), save the text file to d:exopscal.ps1 file, then run d:exopscal.ps1 in PowerShell. All the calendars’ permission in the mailboxes defined in the first line will be changed to full detailed.

Removing is this –

Remove-MailboxFolderPermission -Identity $cal -User

Setting Office 365 User with Send As permission

Connect to O365

$LiveCred = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $LiveCred -Authentication Basic -AllowRedirection

Import-PSSession $Session


Send As

Add-RecipientPermission -AccessRights SendAs -Trustee

View all Send As permissions you’ve configured in your organization :  Get-RecipientPermission | where {($_.Trustee -ne ‘nt authorityself’) -and ($_.Trustee -ne ‘null sid’)}

Remove-RecipientPermission -AccessRights SendAs -Trustee

Converting Office 365 User Mailbox to Shared Mailbox

First connect to Office 365

Connect to O365

$LiveCred = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $LiveCred -Authentication Basic -AllowRedirection

Import-PSSession $Session



Set-Mailbox -Identity mailbox -Type:Shared

Set-Mailbox mailbox -ProhibitSendReceiveQuota 10GB -ProhibitSendQuota 9.75GB -IssueWarningQuota 9.5GB


If your mailbox keeps getting converted back to user mailboxes you may need to try this –