从 Sharepoint 365 获取所有成员的列表

Get a list of all members from Sharepoint 365

当我在 PowerShell 运行 Get-MsolUser | Get-Member | Out-GridView

我收到一个错误 Get-Member : You must specify an object for the Get-Member cmdlet

我在 Google 中找不到任何可以为我指明此错误的正确方向的内容。

您收到此错误是因为以下命令:

Get-MsolUser | Get-Member | Out-GridView

如果连接未建立则抛出异常。话虽如此,您可以考虑以下解决方案:

解决方案 1

使用-InputObject参数:

Specifies the object whose members are retrieved. Using the InputObject parameter is not the same as piping an object to Get-Member. The differences are as follows:

-- When you pipe a collection of objects to Get-Member, Get-Member gets the members of the individual objects in the collection, such as the properties of each string in an array of strings.

-- When you use InputObject to submit a collection of objects, Get-Member gets the members of the collection, such as the properties of the array in an array of strings.

Get-Member -InputObject Get-MsolUser | Out-GridView

解决方案 2

由于Get-MsolUsercmdlet需要建立连接,所以先执行命令Connect-MsolService然后:

Get-MsolUser | Get-Member | Out-GridView