Get Office 365 users that are still running Outlook 2007 in all customer tenants
Outlook 2007 is no longer supporting connections to Office 365 by the end of October, so it’s a good idea to find out whether this affects any of your users. If you’re managing multiple Office 365 tenants, you can use these PowerShell scripts to detect old versions and get your customers up to date. See this Office 2007 end of life article for more info.
This script works by searching the mailbox audit logs of your customers tenants. If you haven’t enabled mailbox auditing, you’ll need to do so, then let it collect data for a few days.
Some things to consider
- To allow these scripts to work with MFA enabled accounts, you may need to whitelist your current static IP.
- This will detect users running Outlook 2007, even if they are also using another Outlook version on a different device.
- These scripts currently don’t support two factor authentication. You may decide to create a temporary delegated administrator for the purpose of executing them.
- These will check the mailbox audit logs for connections via Outlook 2007 to Office 365 in the last 5 days. You can modify the Search-MailboxAuditLog cmdlet to a shorter date period if you experience performance issues.
How to enable mailbox auditing for customers’ Office 365 tenants
- Follow this quick guide to enable mailbox auditing for your tenant, or all customer tenants.
- Wait a few days for the audit logs to collect data.
How to find users on Outlook 2007 in your own Office 365 tenant
- Copy and run the following script in Visual Studio Code or PowerShell ISE
# Establish a PowerShell session with Office 365. You'll be prompted for your Exchange Admin credentials $CSVpath = "C:\Temp\outlookversions.csv" $credentials = Get-Credential Write-Output "Getting the Exchange Online cmdlets" $Session = New-PSSession -ConnectionUri https://outlook.office365.com/powershell-liveid/ ` -ConfigurationName Microsoft.Exchange -Credential $credentials ` -Authentication Basic -AllowRedirection Import-PSSession $Session $mailboxes = Get-Mailbox -ResultSize Unlimited | Where-Object {$_.RecipientTypeDetails -match "User"} foreach ($mailbox in $mailboxes) { Write-Output "Checking $($mailbox.DisplayName)" $result = $null $properties = $null $result = Search-MailboxAuditLog -StartDate ([system.DateTime]::Now.AddDays(-5)) -EndDate ([system.DateTime]::Now.AddDays(1)) -Operations MailboxLogin -Identity $mailbox.UserPrincipalName -ShowDetails | where-object {$_.ClientInfoString -match "Office/12" } | Select-Object LogonUserDisplayName, ClientInfoString, LastAccessed, ClientIPAddress -First 1 if ($result) { $properties = @{ LogonUserDisplayName = $result.LogonUserDisplayName EmailAddress = $mailbox.PrimarySmtpAddress ClientInfoString = $result.ClientInfoString LastAccessed = $result.LastAccessed ClientIPAddress = $result.ClientIpAddress } $forcsv = New-Object psobject -Property $properties $forcsv | Export-CSV -Path $CSVpath -Append -NoTypeInformation } } Remove-PSSession $Session
- Wait for it to complete
- See the exported results in a CSV in C:\temp\outlook2007.csv
How to find users on Outlook 2007 in all customer tenants
This is a long running script that will collect and export detected users with Outlook 2007 as it finds them. Depending on how many users you’re managing, you may want to give this a couple of hours to process.
- Copy and run the following script in Visual Studio Code or PowerShell ISE
# Establish a PowerShell session with Office 365. You'll be prompted for your Delegated Admin credentials $Cred = Get-Credential Connect-MsolService -Credential $Cred $customers = Get-MsolPartnerContract Write-Host "Found $($customers.Count) customers for $((Get-MsolCompanyInformation).displayname)." $CSVpath = "C:\Temp\outlookversions.csv" foreach ($customer in $customers) { $InitialDomain = Get-MsolDomain -TenantId $customer.TenantId | Where-Object {$_.IsInitial -eq $true} Write-Host "Getting Outlook Versions for $($Customer.Name)" $DelegatedOrgURL = "https://outlook.office365.com/powershell-liveid?DelegatedOrg=" + $InitialDomain.Name $s = New-PSSession -ConnectionUri $DelegatedOrgURL -Credential $Cred -Authentication Basic -ConfigurationName Microsoft.Exchange -AllowRedirection Import-PSSession $s -CommandName Get-Mailbox,Search-MailboxAuditLog -AllowClobber $mailboxes = Get-Mailbox | Where-Object {$_.RecipientTypeDetails -match "User"} foreach ($mailbox in $mailboxes) { Write-Output "Checking $($mailbox.DisplayName)" $result = $null $properties = $null $result = Search-MailboxAuditLog -StartDate ([system.DateTime]::Now.AddDays(-5)) -EndDate ([system.DateTime]::Now.AddDays(1)) -Operations MailboxLogin -Identity $mailbox.UserPrincipalName -ShowDetails | where-object {$_.ClientInfoString -match "Office/12" } | Select-Object LogonUserDisplayName, ClientInfoString, LastAccessed, ClientIPAddress -First 1 if ($result) { $properties = @{ CustomerName = $customer.Name LogonUserDisplayName = $result.LogonUserDisplayName EmailAddress = $mailbox.PrimarySmtpAddress ClientInfoString = $result.ClientInfoString LastAccessed = $result.LastAccessed ClientIPAddress = $result.ClientIpAddress } $forcsv = New-Object psobject -Property $properties $forcsv | Export-CSV -Path $CSVpath -Append -NoTypeInformation } } Remove-PSSession $s }
- Wait for it to complete.
- See the exported results in a CSV in C:\temp\outlook2007.csv
Leave a Reply
Want to join the discussion?Feel free to contribute!