【发布时间】:2018-11-18 18:49:24
【问题描述】:
我在 powershell Get-CsUser 中运行此命令,我收到以下错误
Get-CsUser : The term 'Get-CsUser' 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. At line:1 char:1
+ Get-CsUser
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-CsUser:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我该怎么做才能避免这个错误?我已经导入:
Import-Module "C:\Program Files\Common Files\Skype for Business Online\Modules\SkypeOnlineConnector\SkypeOnlineConnector.psd1"
然后使用以下脚本连接到 Office 365 Skype for business 服务:
$credential = Get-Credential
Import-Module MSOnline
Connect-MsolService -Credential $credential
Import-Module SkypeOnlineConnector
$lyncSession = New-CsOnlineSession -Credential $credential
Import-PSSession $lyncSession
有谁知道这个错误的原因是什么?
【问题讨论】:
-
导入
.psm1文件,而不是.psd1 -
@cet51 这不是问题。 OP:我没有看到您在代码示例中的任何地方使用
Get-CsUser。 -
@cet51 是的,它会在文件夹中搜索同名的模块清单(这是模块加载的一般工作方式,它查看 psd1 文件以告诉它要做什么)。不过,这个问题没有足够的细节来说明问题所在。
标签: powershell office365 skype-for-business