Category Archives: Mail

How To Restore User Mailboxes in Office 365

Restore one or more users

When you restore a user account within 30 days after deleting it, the user account and all associated data are restored. The user can sign in to Office 365 with the same user ID, their mailbox is fully restored, and they have access to all services they previously accessed.

Before you restore a user account, make sure there are Office 365 licenses available that you can assign to the account. Also, when you restore an account, you may encounter conflicts with user names or proxy addresses, which you can resolve.

To restore one or more users

  1. Go to Admin > Office 365 > Users and groups > Deleted users.
  2. On the Deleted users page, choose the names of the users that you want to restore, and then click Restore users.
  3. In the confirmation box, click Close.

Delete or restore users – office365 suite.

How Connect to Exchange Online Office 365 using remote PowerShell

Remote PowerShell allows you to manage your Exchange Online settings from the command line. You use Windows PowerShell on your local computer to create a remote Shell session to Exchange Online. It’s a simple three-step process where you enter your Exchange Online credentials, provide the required connection settings, and then import the Exchange Online cmdlets into your local Windows PowerShell session so that you can use them.

 

What do you need to know before you begin?

·        

Estimated time to complete: 5 minutes

·         You can use the following versions of Windows:

o    Windows 8 or Windows 8.1

o    Windows Server 2012 or Windows Server 2012 R2

o    Windows 7 Service Pack 1 (SP1)*

o    Windows Server 2008 R2 SP1*

·         You need to install the Microsoft .NET Framework 4.5 or 4.5.1 and then either the Windows Management Framework 3.0 or the Windows Management Framework 4.0.

 

Connect to Exchange Online

 

1.     On your local computer, open Windows PowerShell and run the following command.

2.     $UserCredential = Get-Credential

In the Windows PowerShell Credential Request dialog box, type your Exchange Online user name and password, and then click OK.

3.     Run the following command.

4.     $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

5.     Run the following command.

6.     Import-PSSession $Session
7.     Be sure to disconnect the remote PowerShell session when you're finished. If you close the Windows PowerShell window without disconnecting the session, you could use up all the remote PowerShell sessions available to you, and you'll need to wait for the sessions to expire. To disconnect the remote PowerShell
               Remove-PSSession $Session
How do you know this worked?

 

After Step 3, the Exchange Online cmdlets are imported into your local Windows PowerShell session as tracked by a progress bar. If you don’t receive any errors, you connected successfully. A quick test is to run an Exchange Online cmdlet—for example, Get-Mailbox—and see the results.

If you receive errors, check the following requirements:

·         A common problem is an incorrect password. Run the three steps again and pay close attention to the user name and password you enter in Step 1.

·         To help prevent denial-of-service (DoS) attacks, you’re limited to three open remote PowerShell connections to your Exchange Online organization.

·         Windows PowerShell needs to be configured to run scripts. You only need to configure this setting once on your computer, not every time you connect. To enable Windows PowerShell to run signed scripts, run the following command in an elevated Windows PowerShell window (a Windows PowerShell window you opened by selecting Run as administrator).

·         Set-ExecutionPolicy RemoteSigned

 

·         The account you use to connect to Exchange Online must be enabled for remote Shell. TCP port 80 traffic needs to be open between your local computer and Exchange Online. It’s probably open, but it’s something to consider if your organization has a restrictive Internet access policy.

Connect to Exchange Online using remote PowerShell: Exchange Online Help.

How To Delete User Mailboxes in Office 365

·         You can delete Exchange Online mailboxes by deleting the corresponding Office 365 user account, removing the Exchange Online license, or by running the Remove-Mailbox cmdlet in the Shell.

·         When a mailbox is deleted, Exchange Online retains its contents for 30 days, by default. After 30 days, the mailbox is permanently deleted and is not recoverable.

·         You can recover a deleted mailbox within the retention period by using the Office 365 admin center to recover the corresponding Office 365 user account.

·         If the mailbox was deleted by removing the Exchange Online license, it can be restored within the retention period by reassigning the license to the corresponding user account. 

·         If you need to delete a mailbox, but preserve the mailbox contents indefinitely, you can enable an inactive mailbox. To do this, you have place the mailbox on In-Place Hold before you delete it. 

·         Before an inactive mailbox can be enabled, the mailbox must be assigned an Exchange Online (Plan 2) license or have an Exchange Online Archiving subscription so that an In-Place Hold can be placed on the mailbox before it’s deleted.

Use the Office 365 admin center to delete a user account

1.     Go to Admin > Office 365 > Users and groups.

2.     Choose the names of the users that you want to delete, and then click Delete .

3.     In the confirmation box, click yes.

Use the Shell to delete a mailbox

1.     Connect to Exchange Online Using Remote PowerShell:

a.     Run PowerShell as administrator.

b.    Configure PowerShell to run scripts. Set-ExecutionPolicy RemoteSigned

c.     $UserCredential = Get-Credential

d.    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic –AllowRedirection

e.     Import-PSSession $Session

2.     Remove-Mailbox -Identity “Nellie Rom”

3.     Disconnect the remote PowerShell session:

 

a.     Remove-PSSession $Session

via Delete or Restore User Mailboxes in Exchange Online: Exchange Online Help.

How to get a list of all Licensed Office 365 users with PowerShell

Install required software

1.     Ensure you are running Windows 8.1, Windows 8, or Windows 7.

2.     Make sure you have the .NET Framework 3.51 feature.

3.       Make sure you have the latest updates.

4.     Install the Microsoft Online Services Sign-In assistant.

5.       Install the Windows Azure Active Directory (Azure AD) module for the appropriate version of your operating system.

6.       Open powershell as administrator.

7.       Import-Module MSOnline

8.       Get-Credential (Windows PowerShell  dialog box appears)

9.       Enter your credentials.

10.   Connect-MsolService

11.   Get-MsolUser -All |Sort isLicensed

12.   Finish.

Via – Getting Started with Office 365 and PowerShell – Hey, Scripting Guy! Blog – Site Home – TechNet Blogs.

Office 365 Increase Inbox ‘Rules Quota’ limit

Only Office 365 Tenant Admins can increase the ‘Rules Quota’ limit for their users, a user himself without the Administrator rights/permissions cannot increase his rules limit.

You will need to use Windows PowerShell in Exchange Online to do this.

  1. Install and configured Windows PowerShell and Windows Remote Management (WinRM) on your computer.
  2. Connect the Windows PowerShell on your local computer to the cloud-based service to perform tasks in your cloud-based organization.
  3. Click Start, point to All Programs, click Accessories, click Windows PowerShell, and then click Windows PowerShell.
  4. Run the following command: $LiveCred = Get-Credential
  5. In the Windows PowerShell Credential Request window, type the credentials of an account in your cloud-based organization. Then, click OK.
  6. Run the following command: $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic –AllowRedirection
  7. Run the following command: Import-PSSession $Session
  8. Current Rules Quota Limit

To determine the current ‘Rules Quota’ limit for a user or mailbox, run the following command in the Windows PowerShell module:

get-mailbox -identity <mailbox> | fl *rulesquota*

Where <mailbox> could be the user’s UPN (User Principal Name) or full e-mail address, like john@contoso.onmicrosoft.com as in the example below.

get-mailbox -identity john@contoso.onmicrosoft.com | fl *rulesquota*

The output you can expect to see will be:

RulesQuota : 64 KB (65,536 bytes)

This is the default ‘Rules Quota’ limit for all users in Office 365.

  1. Increase Rules Quota Limit

To increase ‘Rules Quota’ limit for a particular user or mailbox, run the following command in the Windows PowerShell module:

  1. set-mailbox -identity <mailbox> -RulesQuota <xxx>kb
  2. where <mailbox> could be the user’s UPN (User Principal Name) or full e-mail address, like john@contoso.onmicrosoft.com & you can replace <xxx>kb with an appropriate size that you desire for that user, like 150kb, as in the example below.
  3. set-mailbox -identity john@contoso.onmicrosoft.com -RulesQuota 150kb

The maximum ‘Rules Quota’ limit allowed for a user or mailbox is 256KB.

  1. Disconnect Windows PowerShell from the cloud-based service
  2. When you’re finished using the server-side session, always disconnect Windows PowerShell by running the following command: Remove-PSSession <session variable> For example, to disconnect from the server-side session that is defined by the $Session variable, run the following command: Remove-PSSession $Session
  3. Important   If you close the Windows PowerShell window without disconnecting from the server-side session, your connection will remain open for 15 minutes. Your account can have only three connections to the server-side session at one time.

Example:

Windows PowerShell

Copyright (C) 2013 Microsoft Corporation. All rights reserved.

PS C:\Users\guy.naftaly> $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection

WARNING: Your connection has been redirected to the following URI: “https://pod51048psh.outlook.com/powershell-liveid?PSVersion=4.0

PS C:\Users\guy.naftaly> Import-PSSession $Session

WARNING: The names of some imported commands from the module ‘tmp_1fjp3qw5.v5z’ include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a

list of approved verbs, type Get-Verb.

 

ModuleType Version    Name                                ExportedCommands

———- ——-    —-                                —————-

Script     1.0        tmp_1fjp3qw5.v5z                    {Add-AvailabilityAddressSpace, Add-DistributionGroupMember, Add-MailboxFolderPermission, Add-MailboxPermission…}

 

PS C:\Users\guy.naftaly> get-mailbox -identity xxx@xxx.com | fl *rulesquota*

RulesQuota : 64 KB (65,536 bytes)

 

PS C:\Users\guy.naftaly> set-mailbox -identity xxx@xxx.com -RulesQuota 256kb

PS C:\Users\guy.naftaly> Remove-PSSession $Session

PS C:\Users\guy.naftaly>

Links:

http://community.office365.com/en-us/w/exchange/2490.aspx

http://help.outlook.com/en-us/140/cc952755.aspx

 

Getting Mailbox Sizes in PowerShell

In earlier versions of Exchange, we could look in the Exchange console and see mailbox sizes on a per database basis. Not bad, but better than what we have in the Exchange 2007 GUI.

Fortunately, we can use PowerShell to see the information we need. And, we have more control over how the information is displayed, as well as what information is displayed. Let’s fire up PowerShell and get started.

We can use the Get-MailboxStatistics cmdlet and supply a username like this:

Get-MailboxStatistics [username]

This shows the DisplayName, ItemCount, StorageLimitStatus, and LastLogonTime fields for the specified user.

But that doesn’t show what we need. We can have the cmdlet display just specific fields, such as DisplayName, ItemCount, and TotalItemSize, which will show the size of the mailbox. For that, we use the FT command, short for Format-Table, along with the fields we want.

Get-MailboxStatistics [username] | ft DisplayName, TotalItemSize, ItemCount

This shows us the size of the mailbox in bytes, as well as the number of items, and the username.

Showing data for all users

Now that we can see the specific fields, we can remove the [username] parameter and the command will show us the information all users.

Filtering results

As you can see, this will show us system mailbox sizes as well, which probably doesn’t do us any good. So let’s filter them out.

We add | where {$_.ObjectClass –eq “Mailbox”} right after Get-MailboxStatistics to help.

Note – that’s a pipe at the beginning. This code essentially says to only display those objects classified as mailboxes. From that, we get a cleaner list.

Sorting results

So that shows us all of the users and their sizes, but they appear in a random, unsorted order, which doesn’t do anyone any good. In PowerShell, we can sort using the Sort-Object cmdlet. Right after our filter, we add

| Sort-Object TotalItemSize –Descending

 

This tells PowerShell to sort according to the TotalItemSize parameter (the size of the mailbox) of the Get-MailboxStatistics results, in descending order.

Via Getting Mailbox Sizes in PowerShell.