by zilchers · 7y ago · 0 comments
Import-Csv -Path $src | foreach { $file = $_.column8 Write-Verbose "Writing to $file" Export-Csv -Path (Join-Path -Path $dstDir -ChildPath "$($file).csv") -InputObject $_ -Append -Encoding ASCII -NoTypeInformation
ipcsv $src|group column8|%{$_.group|epcsv "$dstdir\$($_.name).csv" -noty -e ascii -v}
The bad part is when writing "good" powershell the verbosity is exponentially worse and it turns into try
{
if (-not [string]::IsNullOrEmpty($_.Column8))
{
$fullPathName = Join-Path -Path $dstDir -ChildPath $_.Column8
$pathTestResult = test-path -LiteralPath $fullPathName -ErrorAction Stop
# This is a hashtable of the parameters to a cmdlet
# the only purpose of this 'splatting' is that
# powershell commands get too long
# and can't be line-wrapped in any good way
$exportParams = @{
Encoding = 'ASCII'
NoTypeInformation = $true
Append = $true
LiteralPath = $fullPathName
Verbose = $true
}
Export-Csv $exportParams
}
}
catch [whatever]
{
}
and on and on and on, ugh.