因此,对于excel csv文件,当至少一个更改请求编号在“分配组”列中具有一个单元格时,我试图摆脱在“分配组”列中具有空单元格的所有重复的更改请求号。不是空的(值是to-io.got,to-io.got-app,to-io.got-proc'),因此它应该看起来像这样。
但是我不想删除重复的更改请求编号,这些更改请求编号在它们的分配组中有一个(to-io.got,to-io.got-app,to-io.got-proc),我不想删除单个更改请求号,无论其在“分配组”列中具有空单元格还是在“分配组”中具有(to-io.got,to-io.got-app,to-io.got-proc)作为值。
所以如何编写脚本,使其符合我在文章顶部解释的条件,当我获得excel文件时,它看起来像这样:
之前:
Change request Change Title Technology Portfolio Driver Planned Start Date Planned End Date Phase Change Type Opened By Task Description Task Number Assigned To Assignment Group Technology Portfolio Impacted
CHG0706484 PROD - EDTS - Scan Package (Lost/Stolen, Bankruptcy, Outgoing Credit) Deployment CCT-Retail Operations Technology 9/14/2019 21:00 9/15/2019 12:00 Implement FastLane Evan Chambers (chambere) CCT-Retail Operations Technology
CHG0706484 PROD - EDTS - Scan Package (Lost/Stolen, Bankruptcy, Outgoing Credit) Deployment CCT-Retail Operations Technology 9/14/2019 21:00 9/15/2019 12:00 Implement FastLane Evan Chambers (chambere) Deploy Package CTASK1182048 Kumaran Sugumaran (sugumara) to-io.got-app CCT-Retail Operations Technology
后:
Change request Change Title Technology Portfolio Driver Planned Start Date Planned End Date Phase Change Type Opened By Task Description Task Number Assigned To Assignment Group Technology Portfolio Impacted
CHG0706484 PROD - EDTS - Scan Package (Lost/Stolen, Bankruptcy, Outgoing Credit) Deployment CCT-Retail Operations Technology 9/14/2019 21:00 9/15/2019 12:00 Implement FastLane Evan Chambers (chambere) Deploy Package CTASK1182048 Kumaran Sugumaran (sugumara) to-io.got-app CCT-Retail Operations Technology
这是我作为脚本尝试的内容:
$GroupArray2 = @(
'to-io.got'
'to-io.got-app'
'to-io.got-proc'
)
$items4 = Import-Csv -Path 'C:\Temp\Excel6.csv' | Group-object -Property 'Change Request' | Where-Object count -gt 1 | Where-object {$_.'Assignment Group' -in $GroupArray2} | Foreach-object { $selections3 = $_.Group | Select-Object -Property * }
$items4 | Export-CSv -path 'C:\Temp\Excel7.csv' -NoTypeInformation
但是当我尝试时它不会输出任何东西。任何帮助,将不胜感激!
[在检查$_.'Assignment Group' -in $GroupArray2
位置之前,需要按组分开对象
$items4 = Import-Csv -Path 'C:\Temp\Excel6.csv' | Group-object -Property 'Change Request' | Where-Object count -gt 1 | ForEach-Object {$_.group} | Where-object {$_.'Assignment Group' -in $GroupArray2}
如果我正确理解了这个问题,那应该起作用