2016-02-05 176 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模块”。 :( –