# Office 365 – The following error occurred during validation in agent Archive ParameterSet Enforcement Agent

If you try to use Enable-Mailbox for cloud-only Office 365 users, Exchange Online can return an Archive ParameterSet Enforcement Agent error because the mailbox really needs licensing, not on-prem style mailbox enablement.

blog

26 Sep 2018 de

![Office 365 – The following error occurred during validation in agent Archive ParameterSet Enforcement Agent](/wp-content/uploads/2018/09/img_5babe3fc37b8d.png)

[Bilder ansehen (3)](#pf-content-image-1-0)

I created a batch of **Azure AD** users with **PowerShell** and then moved to the next obvious step: make them mail-enabled. On-premises habits kicked in, so `Enable-Mailbox` felt like the natural cmdlet to reach for.

That assumption was wrong for this scenario.

## What I tried

The original command looked like this:

```powershell
foreach ($User in $UsersNonExistantAzure) {
    Enable-Mailbox -Identity $User.MailNickName -WhatIf
}
```

[!\[Enable-Mailbox command being run against Azure AD users in Office 365 before the mailbox licensing fix.\](/wp-content/uploads/2018/09/img_5babe3fc37b8d.png)](/wp-content/uploads/2018/09/img_5babe3fc37b8d.png)

And the result was this error:

> WARNING: After you create a new mailbox, you must go to the Office 365 Admin Center and assign the mailbox a license, or it will be disabled after the grace period. The following error occurred during validation in agent 'Archive ParameterSet Enforcement Agent': 'This operation only works with Archive or PermanentlyDisable parameters.'

[!\[Office 365 PowerShell error showing Archive ParameterSet Enforcement Agent validation failure in Enable-Mailbox.\](/wp-content/uploads/2018/09/img_5babe229d6163.png)](/wp-content/uploads/2018/09/img_5babe229d6163.png)

## What was actually wrong

The real issue was not archiving at all. The problem was that these were **cloud users** in **Office 365 / Exchange Online**, and what they needed was an **Exchange Online license**, not an on-premises-style mailbox enablement step.

That is an easy trap if you work with both on-premises Exchange and Microsoft 365, because the cmdlet names make the workflows sound more similar than they really are.

## Fix

For this case, the fix was simply to assign a license that includes **Exchange Online**:

```powershell
Set-MsolUserLicense -UserPrincipalName $User.UserPrincipalName -AddLicenses "evotec:ENTERPRISEPACK"
```

After that, mailbox provisioning started behaving as expected:

[!\[Exchange Online mailbox list after assigning licenses to users and completing the mailbox activation workflow.\](/wp-content/uploads/2018/09/img_5babe76e0d363.png)](/wp-content/uploads/2018/09/img_5babe76e0d363.png)

And the mailboxes began to appear in **Exchange Online**.

## Practical takeaway

If the users are **cloud-only** and you are working in **Exchange Online**, think licensing first. `Enable-Mailbox` is the wrong mental model for most of those bulk provisioning cases.

## Current note

The provisioning lesson in this post still holds. Microsoft documents that when you assign a user an **Exchange Online license**, the mailbox is created automatically.

The historical part is the tooling example: `Set-MsolUserLicense` comes from the old **MSOnline** module, and Microsoft has deprecated and retired the legacy **MSOnline** and **AzureAD** modules. So if you are automating this today, keep the workflow idea, but use current Microsoft 365 / Entra / Microsoft Graph-based tooling instead of building new scripts around MSOnline.

## Zugehörige Projekte

Projekte, die zu Tags, Kategorien und Inhalt dieses Beitrags passen.

[Alle Projekte](/de/projekte/)

Projekte werden abgeglichen...

[Zurück zum Blog](/blog)

## Ähnliche Beiträge

- [Sending email as an alias (proxy address) with Office 365](/de/blog/sending-email-as-an-alias-proxy-address-with-office-365/)
- [Creating Visual Indicators for spoofed / external emails with PowerShell](/de/blog/creating-visual-indicators-for-spoofed-external-emails-with-powershell/)
- [Office 365 – Report containing User Information and Mailbox Usage](/de/blog/office-365-report-containing-user-information-and-mailbox-usage/)

<!-- PowerForge markdown artifact sha256:595E9634BB1DEF6E1F75D9E224B291E47EF67C8918880C4CA05B33EFA18D015D -->
