【发布时间】:2017-11-08 01:58:08
【问题描述】:
如果您想要完整的脚本分解以及我目前获得的结果,可以参考我之前的帖子。
Import the items from the pipeline in to an array
我试图弄清楚如何从数组中只获取我需要的两个字段,以便我可以操作数据。现在数组将整行显示为数组中的第一个元素。
$Date = (Get-Date -format "MM-dd-yyyy")
$DateTime = (Get-Date)
$Projects = Import-Csv c:\temp\pm_project.csv
#Show me the entire list of Projects
$Projects
$TS_Entries = Get-Content "c:\temp\timesheet\$Date.txt"
#Show me all the chosen entries in the text file
$TS_Entries
#Show me only the lines in the text file that match the regex statement
$TS_Entries = Select-String -Path "C:\temp\TimeSheet\$Date.txt" -Pattern '(?>FOAH|PRJ)\d{1,10}' -allmatches | Select-Object -expand matches | Select-Object -expand Value
$TS_Entries
$TS_Entries | group -NoElement
我似乎无法利用数组中的计数元素。我需要获取 Count 中每个值的值并将它们乘以 15。我可以在下面的列表中引用的唯一内容是 Name
Count Name
----- ----
2 FOAH278
1 FOAH519
1 FOAH704
3 FOAH718
2 FOAH780
【问题讨论】:
-
试试
Flatten-Object: $TS_Final |展平对象 -
能否请您提供一个示例文本行?这样会更容易提供帮助。
-
@Snak3d0c 我已经放了一个链接到我的另一篇文章,该文章显示了从脚本到问题区域的结果。 stackoverflow.com/questions/47148500/…
-
@Snak3d0c 在导出到 csv 文件之前,我已经更新了这篇文章底部的结果。希望这会有所帮助。
标签: arrays powershell