Tag Archives: powershell

Manually syncing Azure AD

When Azure Connect is setup the quickest way to fire off a manual sync is through powershell.

For a full sync (new accounts etc):

import-module adsync
Start-ADSyncSyncCycle -PolicyType Initial

For a incremental sync (faster but not as thorough):

import-module adsync
Start-ADSyncSyncCycle -PolicyType delta

I normally save these as .ps1 files on the desktop of the server to I can quickly run them.

Extracting useful user information from Exchange 2010 with Powershell

Finishing a migration to Office 365 and want to send the client a list of remaining user mailboxes that need moving (or deleting!).

get-mailbox and get-mailboxstatistics both have their uses, but I really needed to use something that combined them both.

I found the solution at https://www.experts-exchange.com/questions/28399371/Combining-Get-Mail-Get-Mailboxstatistics-To-Pull-UsageLocation-LastLogonTime.html

And adapted it to my own means:

Get-Mailbox -ResultSize Unlimited | sort-object | Select-Object Name, primarysmtpaddress, @{n="Mailbox Size";e = {$MBXstat = Get-MailboxStatistics $_.name; $MBXstat.TotalItemSize}}, @{n="LastLogonTime";e = {$MBXstat = Get-MailboxStatistics $_.name; $MBXstat.LastLogonTime}} | Export-Csv C:\temp\LastLogonTime.csv

This outputs the User name, Primary SMTP Address from get-mailbox and Mailbox size (formatted to MB) and last logon time from get-mailboxstatistics.