远程login到Exchange 2016configuration时缺lessCore PowerShell命令

我遇到了一个问题,即在远程login到Exchange 2016服务器时,不存在简单的命令(例如Get-Module)。

我正在运行的命令是:

Invoke-Command -ConfigurationName Microsoft.Exchange -ConnectionUri http://SERVERNAME/powershell -Authentication Kerberos -Credential $cred -ScriptBlock { Get-Module } 

结果是:

 The term 'Get-Module' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. + CategoryInfo : ObjectNotFound: (Get-Module:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException + PSComputerName : SERVERNAME 

其他核心命令,如Get-Command,按预期工作 – 包括Exchange命令(Get-Mailbox等)。

我所做的唯一的改变是改变Powershell站点的IIS中的PSLanguageMode为“FullLanguage”。 反转此更改(并重新启动适用的池和站点)不会影响结果。

我不经常处理Exchange或PowerShell,所以任何build议表示赞赏。

Exchange服务器被devise为受限制的端点。 会话configurationMicrosoft.Exchange是一个裸露的骨骼configuration模式,具有有限的暴露方法。 由于Exchange服务器暴露于外部世界,devise人员沉迷于安全性。 您正在尝试使用的命令在您的现有上下文中是微不足道的,因为您在实例化中指定了您想要的环境。

强烈build议您在现有会话configuration(针对远程)内工作,或者在本地运行代码以访问所有方法。 但是,如果您的风险承受力允许,则可以使用您在此处find的信息来创build自定义会话configuration模式。