2016-02-05 177 views
2

Windows 7,PowerShell 4.0。計算機在Windows域中。

我需要獲取SMTP服務器名稱(使用send-mailmessage cmdlet)。 $PSEmailServer爲空。

我讀了this關於Get-AcceptedDomain cmdlet的TechNet頁面。但我看到了這一點(在TechNet頁面上):

This cmdlet is available in on-premises Exchange Server 2016 and in the cloud-based service.

如何獲取SMTP服務器名稱或其IP地址?

+0

我不認爲我曾聽說過SMTP服務定位器,您如何期待這種機制的工作?如果您的組織中部署了Exchange,則可以通過[autodiscovery](https://msdn.microsoft.com/en-us/library/office/jj900169(v = exchg.150).aspx)查找候選服務器),但這似乎有點矯枉過正 –

+1

問問你的本地郵件管理員。認真。對於像smtp和mail這樣的顯而易見的名字,查詢DNS可能會取得一些成功,但這些只是猜測。也許該組織使用雲郵件,在這種情況下,您不僅需要SMTP服務器的名稱。 – vonPryz

+0

不要過分複雜的事情。你可以在你的MS Outlook客戶端中找到它。 'File'>'Account Settings'>'Account Settings'>>雙擊您的電子郵件地址>頂部條目'服務器:xxxx' – DarkLite1

回答

0

假設計算機是部署與Exchange域的成員,並且要使用Exchange作爲STMP繼電器send-mailmessage,你可以要求在AD配置上下文交換配置:

import-module activedirectory 
$ag = "Exchange Administrative Group (ABCDEFGHIJKLM)" #enter your EAD 
$c = "Acme" # Enter your company name (get this form ADSIEdit if unknown) 
$sb = ("CN=Servers,CN=" + $ag + ",CN=Administrative Groups,CN=" + $c + ",CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=staff,DC=hsrw") 

$server = Get-ADObject -Properties cn, msExchSMTPReceiveConnectorFQDN, msExchSmtpReceiveBindings, msExchSMTPReceiveInboundSecurityFlag -SearchBase $sb -filter { objectClass -eq "msExchSmtpReceiveConnector"} 
$server | ft cn, msExchSMTPReceiveConnectorFQDN, msExchSmtpReceiveBindings, msExchSMTPReceiveInboundSecurityFlag 

這會吐取出組織中每個接收連接器的主機名和端口綁定。然後您必須選擇使用哪一個。

因爲我不知道你有多少Exchange知識,我會在這裏停下來。如果有些事情不清楚,就問。

+0

我收到錯誤信息:*指定的'activedirectory'模塊未加載,因爲在其中一個模塊目錄中找不到該模塊的有效文件* –

+0

[您必須安裝模塊。](https ://technet.microsoft.com/de-de/library/dd378937(v = ws.10).aspx) – Marc

+0

Hm ...但在該頁面上,我看到:* Active Directory-Modul有以下版本Windows Server 2008 R2和Windows 7:... Windows 7 *。 我有Windows 7.我也沒有看到「Windows PowerShell的Active Directory模塊」。 :( –