我写了下面的powershell:
$Headers = @(
"Purchase Order"
"SKU"
"Markdown"
"Landed Cost"
"Original Price"
"Current Sale Price"
"Free Stock"
"OPO"
"ID Style"
"Supplier Style No")
$Location = "\\dc1\shared\BI\HisRms"
$Destination = "C:\Users\jonathon.kindred\Desktop\RMM\"
$files = Get-ChildItem $location -Recurse -Filter "*.csv"
Foreach ($file in $files) { Select $Headers | Export-Csv Join-Path "C:\Users\jonathon.kindred\Desktop\RMM\" $_.FullName -Force -NoTypeInformation}
我遇到的问题是它在所有文件上都失败了,因为我没有硬编码文件路径以使 .csv 结尾。它是怎么做的,所以我加入路径 $Destination 和原始文件名?