string - 在Powershell中迭代字符串的通用列表(Lync聊天室成员)

标签 string powershell generic-list lync

我无法遍历Powershell中的通用字符串列表。该对象是Lync聊天室的成员。获取通用列表的命令:

$crMembers = get-csPersistentChatroom -identity "XXXX" | select members

尝试读取通用列表中的字符串时收到的错误是:
WARNING: An error ocurred: Cannot convert value 
"@{Members=System.Collections.Generic.List`1[System.String]}" to type 
"System.Collections.Generic.List`1[System.String]". Error: "Cannot convert the 
"@{Members=System.Collections.Generic.List`1[System.String]}" value of type 
"Selected.Microsoft.Rtc.Management.Chat.Cmdlets.ChatRoom" to type 
"System.Collections.Generic.List`1[System.String]"."

我也尝试过这个没有成功:
foreach ($Member in $crMembers.GetEnumerator())
{
    Write-Host $Member
}

如何迭代“@ {Members = System.Collections.Generic.List`1 [System.String]}” 且没有错误?

最佳答案

您的列表是$ crMembers对象的属性,称为“Members”,因此

Foreach ($Member in $crMembers.Members)
 {...}

关于string - 在Powershell中迭代字符串的通用列表(Lync聊天室成员),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30099674/

相关文章:

mysql - 如何在 mySQL 中将日期转换为字符串?

vb.net - 创建一个不能从外部更改的 List 属性

arrays - 如何索引汇编中的字符串

c - 为什么strtok_s在第一次使用后返回0x00000001?

android - 为什么我的广播接收器无法识别我的字符串 - 发送短信代码

sorting - 通用排序功能的最通用可能/有意义的签名

arrays - Powershell阵列:何时使用它们;什么时候避免他们和使用它们的问题

powershell - 如何使用 Powershell System.Net.WebClient 和自定义用户代理字符串下载文件?

excel - PowerShell + Excel - $workbook.save() 挂断了我的电话

variables - 带变量的 Powershell 复制文件