2011-07-28 40 views
1

我正在使用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(); 
     } 

回答

1

從文檔:

此參數適用於基於雲的服務對象。它不適用於本地部署。

此參數可用於多租戶部署。它不適用於本地部署。有關多租戶部署的更多信息,請參閱多租戶支持。

Password參數重置與基於雲的郵箱關聯的用戶帳戶的密碼。

+0

那麼如何重置密碼? –

0

如果您使用的是本地Exchange,則設置密碼是AD帳戶管理功能。根據您的域級別,您可以使用ADSI,RSAT工具中的AD模塊或Quest AD cmdlet。