我该如何编码以按以下顺序输出列:
unique_sis_group_id, unique_sis_user_id, unique_sis_school_id, mm_admin
我的代码:
$objs = @();
$output = Import-Csv -Path "c:\users\patrick\desktop\RelayFiles\RelayMemberships\file2concatenate.csv" | ForEach {
$Object = New-Object PSObject -Property @{
unique_sis_group_id = [String]::Concat($_.unique_sis_group_id, $_.unique_sis_user_id)
unique_sis_user_id = $_.unique_sis_school_id
unique_sis_school_id = $_.mm_admin
mm_admin = 0
}
$objs += $Object;
}
$objs
$objs | Export-Csv -NoTypeInformation c:\users\patrick\desktop\RelayFiles\RelayMemberships\memberships.csv
答案 0 :(得分:1)
您将ForEach-Object
分配给$output
,但实际上没有任何内容输出。
使用[PSCustomObject]
更简单:
## Q:\Test\2019\01\25\SO_54373962.ps1
$CsvIn = "c:\users\patrick\desktop\RelayFiles\RelayMemberships\file2concatenate.csv"
$CsvOut = "c:\users\patrick\desktop\RelayFiles\RelayMemberships\memberships.csv"
$output = Import-Csv -Path $CsvIn | ForEach-Object {
[PSCustomObject]@{
unique_sis_group_id = [String]::Concat($_.unique_sis_group_id, $_.unique_sis_user_id)
unique_sis_user_id = $_.unique_sis_school_id
unique_sis_school_id = $_.mm_admin
mm_admin = 0
}
}
$output
$output | Export-Csv $CsvOut -NoTypeInformation
答案 1 :(得分:0)
这已经解决了。有更好的方法吗?
rateStar.CssClass = "kv-fa";