Solved powershell report output format

Microsoft Visio professional 2003 (full...
February 12, 2014 at 01:27:43
Specs: Windows 7, Dell percision 530
in my powershell at the end i have
$mastersheet=Get-Content $strfileout
$Compsheet=Get-content $strfileoutComp

foreach($line in $Compsheet) {

if (-not($mastersheet -eq $line[0])) {$line[0],$line[1]>>"c:\temp\results.txt"}

the sheet that is read in has servername,status

I am comparing $line 0 to another file to see if it exist , if it does it writes out line[0] and then line[1] everything works fine...

however line[0] and line[1] are on seperate lines , even though they are not read in as [0]and [1] being on seperate lines

Learning in progress..........

See More: powershell report output format

Report •

February 12, 2014 at 07:13:17
✔ Best Answer
No you're not. You're looking at the first token in each line, and checking to see if it's equal to the entire $mastersheet file. If it is, you're exporting both the first and second tokens to the output file.

To answer your question, you're making an array of objects, and that'll cause each element to be printed out on its own line. You need to make a string out of it.

{$line[0] + "," + $line[1]>>"c:\temp\results.txt"}
{"{0},{1}" -f $line[0],$line[1]>>"c:\temp\results.txt"}

How To Ask Questions The Smart Way

message edited by Razor2.3

Report •

February 12, 2014 at 07:44:51
Thank you Razor, this does the trick

Learning in progress..........

Report •
Related Solutions

Ask Question