Microsoft has published some sample PowerShell scripts to help you managing Office 365 and Lync.

These scripts will connect to your Office 365 tenant, display your users list, manage user settings or manage domains and more.

As prerequisite, you must have installed Microsoft Online Sign In Assistant, PowerShell Module for Windows Azure Active Directory, Lync PowerShell and the Framework 4.5

Go to http://www.microsoft.com/en-us/download/details.aspx?id=41953 for download the scripts

Enjoy