【问题标题】:Get-CsUser error powershell获取 CsUser 错误 powershell
【发布时间】: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


【解决方案1】:

有谁知道这个错误的原因是什么?提前谢谢你

问题是 Office 365 skype for business没有在用户 cmdlet 下有命令“Get-CsUser”。

可用的用户 cmdlet 如下所示。

Set-CsUser

Get-CsUserPstnSettings

Set-CsUserPstnSettings

Get-CsUserSession

来源“Skype for Business Online cmdlets

Get-CsUser 可用于本地 lync 服务器。
.

PS: 您的“office 365 skype for business”连接和会话导入应该没问题,例如,如果您键入 Get-CsUserSession,它不应说“‘Get-CsUserSession’一词未被识别为cmdlet、函数、脚本文件或可运行程序的名称"

(1) 您可以在导入的模块中查看可用的命令

Get-Command -Module MSOnline
Get-Command -Module SkypeOnlineConnector

(2) 您还可以使用 Get-Command 和您的临时会话名称查看当前会话中的可用命令。

Get-Command -Module tmp_aqu5qmxt.frb

tmp_aqu5qmxt.frb 是我的临时会话 id 名称.. 将其更改为您在此屏幕上看到的任何内容。

(3) 要查看所有导入的命令,您可以使用所有来源(模块+会话),

Get-Command -ListImported

他们都没有名为“Get-CsUser”的命令

【讨论】:

  • 非常感谢您的详细解答。我想做的是获取 Office 365 Skype for Business 的用户列表:我使用您的命令来更好地理解(我对 PowerShell 很陌生),然后在互联网上搜索了更多内容并遇到了这个命令:Get-Msoluser,也许我可以用这个。如果您有任何其他建议,请执行。再次感谢您。
  • 如果是关于商业用户的 Skype,使用 Get-CsOnlineUser 而不是 Get-Msoluser。示例 > docs.microsoft.com/en-us/powershell/module/skype/…
【解决方案2】:

在 Skype for Business Online 中,您应该使用 Get-CsOnlineUser 而不是 Get-CsUser

documentation os Get-CsUser 中所述,它不适用于 Skype for Business Online。

如果您使用Get-Command Get-Cs*User,您只会找到以下 3 个命令:

获取-CsOnlineDialInConferencingUser

获取-CsOnlineUser

获取-CsOnlineVoiceUser

第二个是您应该用来显示在线用户的那个。我已经要求对 MS 文档进行更改,以将其作为提示,希望他们能接受。

【讨论】:

    猜你喜欢
    • 2021-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多