I’m using powershell command to reset password for an existing mailbox, however, it comes out an error message says “A parameter cannot be found that matches parameter name ‘Password’.” It’s weird, because the ‘Password’ is a parameter according to MSDN http://technet.microsoft.com/en-us/library/bb123981.aspx. Did I miss something?
My code:
using (Runspace remoteRunspace = RunspaceFactory.CreateRunspace(connectionInfo))
{
try
{
remoteRunspace.Open();
PowerShell ps = PowerShell.Create();
ps.Runspace = remoteRunspace;
ps.AddCommand("Set-Mailbox");
string PrincipalName = userId + emailDomain;
ps.AddParameter("Identity", identity);
ps.AddParameter("UserPrincipalName", PrincipalName);
ps.AddParameter("Name", name);
ps.AddParameter("DisplayName", name);
ps.AddParameter("Password", emailPwd);//emailPwd is defined as securestring and set value previously, so it cannot be the exception reason
ps.Invoke();
return true;
}
catch (Exception ex)
{
throw ex;
return false;
}
finally
{
remoteRunspace.Close();
}
From the docs:
This parameter applies to objects in the cloud-based service. It isn’t available for on-premises deployments.
This parameter is available for multi-tenant deployments. It isn’t available for on-premises deployments. For more information about multi-tenant deployments, see Multi-Tenant Support.
The Password parameter resets the password of the user account associated with the cloud-based mailbox.