用于Exchange的Powershell显式远程处理无法从模块中工作

用于Exchange的Powershell显式远程处理无法从模块中工作,powershell,module,exchange-server,powershell-remoting,Powershell,Module,Exchange Server,Powershell Remoting,我正在尝试为用户创建模块,以便他们可以从桌面上运行Exchange cmdlet 当我使用下面的脚本时,它工作得很好 function Enable-ExchangeExplicitRemoting {cmdletbinding()] param( [Parameter(ValueFromPipeline=$true)] [string]$exchServer ) Write-Verbose "Creating PSSession.." $s = New-PSSession -Confi

我正在尝试为用户创建模块,以便他们可以从桌面上运行Exchange cmdlet

当我使用下面的脚本时,它工作得很好

function Enable-ExchangeExplicitRemoting {cmdletbinding()]
param(
[Parameter(ValueFromPipeline=$true)]
[string]$exchServer
)    
Write-Verbose "Creating PSSession.."
$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$exchServer/PowerShell/ -Authentication Kerberos 

Write-Verbose -verbose "Importing PSSession" 
Import-PSSession $s -Verbose -AllowClobber |out-null
}
Enable-ExchangeExplicitRemoting -exchServer "servername"
我能够在远程服务器上运行Exchange cmdlet并获取数据

但是,如果我将此函数添加到现有模块,然后加载此模块,则此函数不会按预期从模块加载

>get-command Enable-ExchangeImplicitRemoting
CommandType     Name
-----------     ----
Function        Enable-ExchangeImplicitRemoting

Enable-VTBExchangeImplicitRemoting -exchServer "servername"

VERBOSE: Importing function 'Add-ADPermission'.
VERBOSE: Importing function 'Add-AvailabilityAddressSpace'.
VERBOSE: Importing function 'Add-ContentFilterPhrase'.
.......    
get-mailbox
The term 'get-mailbox' is not recognized as the name of a cmdlet, function, scrip

也许你需要改变你演讲的范围<代码>$global:s=新PSSession。看到好的一点,但不幸没有帮助