Office 365 PowerShell connection script

If you working with Office 365 PowerShell on daily basis, you may find that it is taking too much time to connect your Office 365 console, especially if you working with multiple tenants. You have to note usernames, passwords for all of the tenants and copy/paste them every time you want to make connection. Below you will find description, how to make it “single command” task.

Because that script will give access to your tenant without typing any username/password, I would suggest that you should not implement that on any public machine. Make sure that you are only person who can execute connection script.

OK, let’s start.

First of all we need to create addition file where encrypted tenant’s password will be stored. As an example create directory “O365Connections” on your C: drive and then create folder “keys” in it.

Start PowerShell prompt and type following command:

Read-Host -Prompt "Enter your tenant password" -AsSecureString | ConvertFrom-SecureString | Out-File "C:\O365Connections\keys\tenant1.key"

Continue reading

Re-connection of Exchange 2007 Mailbox

Sometimes during migration of Mailboxes – especially in cross-forest migrations, some of mailboxes may become corrupted. Mailboxes can fail test Test-MapiConnectiviy, user maybe unable to login into mailbox using OWA or messages just not coming in and not going out.

General solution here is disconnect and then connect mailbox again. You only should keep in mind that when you disconnecting Mailbox all Email addresses will be deleted so there is need to note all of them before disconnection.

Following script will do the work:
Continue reading

MS Exchange 2007 Mailbox Statistics

Lets say you need to get information about all mailbox users in your Microsoft Exchange 2007 organisation. Quotas, mailbox size, item count, time when users logged in last time…

It is easy!

Don’t forget to use following in multi-domain environment : $AdminSessionADSettings.ViewEntireForest=$True

Query for Exchange Management Shell:

Get-Mailbox -ResultSize 'Unlimited' -IgnoreDefaultScope | Select DisplayName, Identity, Database, @{label="IssueWarning(MB)";e={(Get-Mailbox $_).IssueWarningQuota.Value.ToMb()}},@{label="ProhibitSend(MB)";e={(Get-Mailbox $_).ProhibitSendQuota.Value.ToMb()}},@{label="ProhibitSendReceive(MB)";e={(Get-Mailbox $_).ProhibitSendReceiveQuota.Value.ToMb()}},@{label="Uses Database Quota Defaults";e={(Get-Mailbox $_).UseDatabaseQuotaDefaults}}, @{label="TotalSize (MB)";e={(get-mailboxstatistics $_).TotalItemSize.Value.toMB()}}, @{label="Item Count";e={(get-mailboxstatistics $_).ItemCount}}, @{label="Last Logon";e={(get-mailboxstatistics $_).LastLogonTime}}| Export-CSV -Path ".\ExchangeStats.csv"