我正在使用powershell命令重置現有郵箱的密碼,但是會出現錯誤消息,顯示「找不到與參數名稱'Password'匹配的參數。 「這很奇怪,因爲'密碼'是根據MSDN http://technet.microsoft.com/en-us/library/bb123981.aspx的參數。我錯過了什麼? 我的代碼:使用powershell重置郵箱密碼時無法找到密碼參數
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();
}
那麼如何重置密碼? –