给定PowerShell中的项目列表,如何在循环中找到当前项目的索引?
例如:
$letters = { 'A', 'B', 'C' }
$letters | % {
# Can I easily get the index of $_ here?
}
Run Code Online (Sandbox Code Playgroud)
所有这一切的目标是我想使用Format-Table输出一个集合,并添加一个包含当前项目索引的初始列.通过这种方式,人们可以交互式地选择要选择的项目.
powershell ×1