简体   繁体   中英

Powershell - Write Object to File

when I want a full compare of two textfiles linewise I have the correct result when I use:

$test = compare-object -referenceobject $srcobject -differenceobject $compareobject -CaseSensitive
$test = $test | where {$_.SideIndicator -eq "=>"} | select 'InputObject'

But afterwards I have serios issues to simply write this stuff to a file.

When i use:

  1. Out-File, it makes a cut off and I don't want many spaces in the end of each line

  2. Export-CSV, it adds me a " to every line at the beginning and the end

  3. Set-Content, it adds me "@{InputObject=" and a } every line

How can I export the data without these limitations?

Regards,

Alex

Try this -

$test = compare-object -referenceobject $srcobject -differenceobject $compareobject -CaseSensitive
$test = $test | where {$_.SideIndicator -eq "=>"} | *select -ExpandProperty InputObject*

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM