PhillyD
PhillyD

Reputation: 174

Errors when creating an Exchange mailbox using PowerShell commands and parameters

The following PowerShell script attempts to create an Exchange mailbox for a user with (a) a retention policy and (b) an archive quota:

PSCommand command = new PSCommand();

command.AddCommand("Enable-Mailbox");
command.AddParameter("Alias", K2.ProcessInstance.DataFields["Account-ADAlias"].Value.ToString());
command.AddParameter("Identity", K2.ProcessInstance.DataFields["Account-ADAlias"].Value.ToString());
command.AddParameter("Database", K2.ProcessInstance.DataFields["Account-MailboxDatabase"].Value.ToString());

command.AddCommand("Enable-Mailbox");
command.AddParameter("Identity", K2.ProcessInstance.DataFields["Account-ADAlias"].Value.ToString());
command.AddParameter("Archive");

command.AddCommand("Set-Mailbox");
command.AddParameter("Identity", K2.ProcessInstance.DataFields["Account-ADAlias"].Value.ToString());
command.AddParameter("Database", K2.ProcessInstance.DataFields["Account-MailboxDatabase"].Value.ToString());
command.AddParameter("ArchiveQuota", "2GB");
command.AddParameter("ArchiveWarningQuota", "1.8GB");
command.AddParameter("RetentionPolicy", "No Archive Delete after 10years");

powershell.Commands = command;

The following error is generated when the script is run:

Parameter set cannot be resolved using the specified named parameters.

NOTE: The variables staring with "K2.ProcessInstance.Datafields" have all been verified as valid.

I can't figure out how to resolve this error. I've consulted the PowerShell module docs for Exchange. Any guidance appreciated.

Upvotes: 0

Views: 331

Answers (1)

Adam
Adam

Reputation: 4168

Powershell can't figure out which parameter-set you're employing with this specific call.

Enable-Mailbox employs several different parameters-sets. I think there are 13 different parameter-sets the commandlet accepts. By only supplying Alias, Identity, and Database, Powershell can't figure out which parameter-set is being employed so it throws up its hands and gives you that error. This is because those three params are a part of almost every parameter-set in the list (I think Database is omitted from one).

The problem was described (for a different use-case) in the the post PowerShell unable the determine which Parameter Set is in use

Hope this helps!

A-

Upvotes: 1

Related Questions