I have a csv file with the following information:
OS Name: Microsoft© Windows Server© 2008 Standard
OS Version: 6.0.6002 Service Pack 2 Build 6002
System Manufacturer: IBM
System Model: IBM 3850 M2 / x3950 M2 -[7233Z1H]-
I need to use powrshell to read and format the display.. My existing code is this:
$Array = #()
Get-Content <txtfilename> | foreach {
$Test = $_
$Title = $Test.split(":")[0]
$Content = $Test.split(":")[1]
$Obj = New-Object System.Object
$Obj | Add-Member -MemberType NoteProperty -value $Title -Name Title
$Obj | Add-Member -MemberType NoteProperty -value $Content -Name Value
$Array += $Obj
}
$Array | Select Title,Value | Export-Csv <csvfilename> -NoTypeInformation
It displays the information as follows listed:
Title Content
OS Name Microsoft? Windows Server? 2008 Standard
OS Version 6.0.6002 Service Pack 2 Build 6002
System Manufacturer IBM
System Model IBM 3850 M2 / x3950 M2 -[7233Z1H]-
I need the information displayed in a single line like this:
ServerName, OS Name , OS Version, System Manufacture, Sytem model,
TestServer1, Microsoft Windows, 6.0.6002 Service Pack 2, IBM, IBM 3850
Thanks
Here's a second answer for the more advanced case, where you don't know how many unique headers you have or what they're called. As long as they're consistently the same and in the same order, the following will work:
$filePath = "C:\users\chris\desktop\info.txt"
$headers = #()
[int]$headerCount = 0
$endUnique = $false
Get-Content $filePath | % {
$header = ($_.split(':')[0] -replace '\s+', ' ').Trim()
if (($headers -notcontains $header) -and (!$endUnique)){
$headers += $header
$headerCount += 1
}
else{
$endUnique = $true
}
}
$headerRow = ""
$headers | % {$headerRow += $_ + ","}
$headerRow = $headerRow.Substring(0,$headerRow.Length-1)
[int]$i = 1
$outString = ""
Get-Content $filePath | % {
$lineContent = ($_.split(':')[1] -replace '\s+', ' ').Trim()
if ($i -lt $headerCount){
$outstring += $linecontent + ','
$i += 1
}
else{
$outstring += $linecontent + "`r`n"
$i = 1
}
}
$outstring = $headerRow+ "`r`n"+$outstring
I'd like to see the other answers from more advanced PowerShell users.
First, just a quick correction. You say you have a CSV. It looks like you have a formatted text file and you want to make a CSV out of it.
Following that assumption, something like this should get you started. It assumes that the text document has either only those 4 items in it, or those 4 items are repeated multiple times - always in the same order, and without a space in between them. Reformatting text files is never fun without a bunch of examples of how they could look.
That being said, the following should get you started.
[int]$i = 1
$outString = ""
Get-Content C:\users\chris\desktop\info.txt | % {
#Take the line, remove the title, remove whitespaces from inside of the line and trim whitespaces from the outside.
$lineContent = ($_.split(':')[1] -replace '\s+', ' ').Trim()
#Chunk them together...
if ($i -lt 4){
$outstring += $linecontent + ','
$i += 1
}
#or insert a return, new line
else{
$outstring += $linecontent + "`r`n"
$i = 1
}
}
#Add a header row. Now $outstring is your CSV formatted text.
$outstring = "OSName,OSVersion,SystemMfg,SystemModel`r`n"+$outstring
$object = New-Object System.Object
Get-Content TestServer1-OSInfo.txt | % {
If($_.Contains(":")){
$Left = $_.split(":")[0].TrimStart().TrimEnd()
$Right = $_.split(":")[1].TrimStart().TrimEnd()
$object | Add-Member -type NoteProperty -name $Left -value $Right
}
}
$object | Export-Csv TestServer1-OSInfo.csv -NoTypeInformation
Related
I have a text file (file1.txt) with records in different lines
Variable1,2018
Variable2,Jun
Now in my script I would like to store the values in different variables.
Example, I would like my end result to be
Year=2018
Period=Jun
I tried the below logic but it is not solving the purpose as it is storing both values in a single variable.
Get-Content "file1.txt" | ForEach-Object {
$Var=$_.split(",")
$Year=$Var[1]
$Period=$Var[1]
}
Please help.
You can do Something like this, if you want use variable :
$Object=(Get-Content C:\Temp\test.txt).Replace(',', '=') | ConvertFrom-StringData
$Object.Variable1
$Object.Variable2
You could do it using a hash like so:
$h = #{}
Get-Content "file1.txt" | % {
$var = $_.split(",")
$h[$var[0]] = $var[1]
}
$h['Variable1']
Or you could use an object like this:
$o = New-Object psobject
Get-Content "file1.txt" | % {
$var = $_.split(",")
$o | Add-Member -MemberType NoteProperty -Name $var[0] -Value $var[1]
$h[$var[0]] = $var[1]
}
$o.Variable1
Why not use the new-variable cmdlet?
#get content from your file instead
$str = "Variable1,2018","Variable2,Jun"
foreach ($line in $str)
{
$line = $line.split(",")
New-Variable -name $line[0] -Value $line[1]
}
I have a CSV with a lot of headers. It ranges from Column A to AZ. I need to read only the first column of the CSV.
My issue is the last column (comments) bleeds into the first column when opened in notepad++ and it appears to show that it is apart of Column one (host name). When I run my code it reads it as notepad++ does.
I originally convert this from an .xls to a CSV file, is there a way to ensure the last column does not wrap around?
#region - Convert to CVS
$strFileName = "C:\working\Server Count & Status Check ARC 0219183.xlsx"
$strSheetName = 'SCI$'
$strProvider = "Provider=Microsoft.ACE.OLEDB.12.0"
$strDataSource = "Data Source = $strFileName"
$strExtend = "Extended Properties='Excel 8.0;HDR=Yes;IMEX=1';"
$strQuery = "Select * from [$strSheetName]"
$objConn = New-Object
System.Data.OleDb.OleDbConnection("$strProvider;$strDataSource;$strExtend")
$sqlCommand = New-Object System.Data.OleDb.OleDbCommand($strQuery)
$sqlCommand.Connection = $objConn
$objConn.open()
$da = New-Object system.Data.OleDb.OleDbDataAdapter($sqlCommand)
$dt = New-Object system.Data.datatable
$da.fill($dt)
$dt | Export-Csv "C:\working\Server Count & Status Check ARC 0219183.csv" -
NoTypeInformation
$objConn.close()
#endregion
Original Spreadsheet
After trying to gather first column(hostname)
$array=#{}
$ServerStatus = Get-Content "C:\Users\user\Desktop\Scripts\Linux Server
Compare\Server Count & Status Check ARC 0219183.csv" | select -skip 1 |
ConvertFrom-Csv -Header "HostName","Business Application","Technical
Function","Location","Environment","Day Number","Slot
Number","SlotTime","Description","DNS Name","Key Server","Host Name","Public
IP","Server Type","Build Date","Builder","Product Name","Serial
No","Enclosure","Bay","CPU Model","CPU Socket","CPU Cores","Logical
CPU","Memory","Up Time","Kernel Version","OS Type","Version","Patch
level","Multipath Disks?","Multipath Checker?","Customized Fsck?","Splx
Installed?","Splx Running?","Suse Manager Status","RHN Running ?","RHN
Autostart?","Installed Kernel","Available Kernel in
/boot","Hardened","Syslog
Config correct ?","Syslog Running ?","Patrol Running?","Splunk
Installed?","Splunk Running?","Puppet Installed?","Puppet
Running?","Centrify
Version","VM Tools Installed?","VM Tools Running?","Comments"
$ServerStatusObj = new-object Object
$ServerStatusObj | add-member -membertype NoteProperty "Name" -value ""
$ServerStatusObj | add-member -membertype NoteProperty "Origin" -value ""
$array=#{name = $ServerStatus.HostName}
foreach ($name in $array.name){
if($name -ne $null){
$Value = $name
if($name -ne $null){
$ServerStatusObj.name =$Value
$ServerStatusObj.Origin = " Linux Servers"
} #End of IF
else {Write-Output "null"}
Write-Output $ServerStatusObj | export-csv
"C:\Users\user\Desktop\Scripts\Linux Server Compare\ServerStatusParse.csv" -notypeinformation -Append
}
Have an psobject which is assigned with the following values,
echo "A|B|C|X,A|B|C|Y,A|B|C|Z,D|E|F|X,D|E|F|Y,D|E|F|Z
1,3,5,2,3,7" > 'c:\temp\test.csv'
$d = Import-Csv 'c:\temp\test.csv'
$d | select -first 1
A|B|C|X : 1
A|B|C|Y : 3
A|B|C|Z : 5
D|E|F|X : 2
D|E|F|Y : 3
D|E|F|Z : 7
....
I want it be tranformed to arrays,
A,B,C,1,3,5
D,E,F,2,3,7
....
- - - - - -
X Y Z
Is it a concise way to pivot the psobject? The converting function head can be
function Convert($datarow, [string[]]$pivotCols) { ... }
Convert($d, 'X','Y','Z')
Actually it's one of those rare situations where $d being a PSObject doesn't give you any benefits. Here's an example of how you could achieve what you want, although I'm not certain it's the most concise way:
# Transforming input.
$sInput = "A|B|C|X,A|B|C|Y,A|B|C|Z,D|E|F|X,D|E|F|Y,D|E|F|Z
1,3,5,2,3,7"
$sRawNames, $sRawValues = $sInput -split ([System.Environment]::NewLine)
$cRawNames = $sRawNames -split ','
$cRawValues = $sRawValues -split ','
# Grouping fields by name pattern.
$sGroupingPattern = '\|[XYZ]'
$htGrouped = [Ordered]#{}
for ($i = 0; $i -lt $cNames.Count; $i++) {
$sName = $cRawNames[$i] -replace $sGroupingPattern
try {
$htGrouped.Add($sName, #($cRawValues[$i]))
}
catch [ArgumentException] {
$htGrouped[$sName] += $cRawValues[$i]
}
}
# Formatting output.
$cOutput = #()
$htGrouped.GetEnumerator() | ForEach-Object {
$cValues = ($_.Name -split '\|') + $_.Value
$oValues = New-Object -TypeName PSObject
for ($i = 0; $i -lt $cValues.Count; $i++) {
$oValues | Add-Member -MemberType "NoteProperty" -Name $i -Value $cValues[$i]
}
$cOutput += $oValues
}
$cOutput | Format-Table
What could be the best way to resolve a computer name apart from using:
[System.Net.DNS]::GetHostByName('MachineName').HostName
I dont want to import any specific DNS Modules.
You can try the GetHostEntry method:
[Net.DNS]::GetHostEntry("MachineName")
Another way would be to ping it using Test-Connection cmdlet, see this tip
I was in a case where I had to query a specific DNS server, which is not possible directly with .net / powershell. So I ended up with using the good old nslookup :
$client="10.110.10.10"
$ns="10.20.1.10"
(nslookup $client $ns |sls name).toString().split(":")[1].trim()
The following 2 ways to resolve IP's to DNS addresses are the only ones.
It's how you use it that counts.
[Net.DNS]::GetHostEntry("MachineName")
[System.Net.DNS]::GetHostByName('MachineName').HostName
Like I said, It's how you use them.
I have written a script for doing just this.
It takes a list of IP addresses and resolves there DNS.
Later in the script it converts the output to an excel sheet, showing you the results.
Based upon filters you can set the layout.
Now I know not all IP's will be resolved with these methods, that's why I included a function in my script that filters out unresolved IP's and places them to the bottom of the excel sheet.
(Giving every IP a direct link to who.is/whois/ipadress
Here's the script, íf you are interested.
#Get current date
$Date = date -format yyyy-MM-dd
$Company = "Company"
$Company2 = "Company2"
########################
#Define all Paths.
$Path = "C:\inetpub\wwwroot\BlockedIP" #This is where your file's will be saved.
md "$Path\HTML\$Date" -Force |Out-Null
$path2 = "$Path\HTML\$Date"
$PathWeb = "/ResolvedIp/HTML/$Date"
########################
#Define File's used or created in this script.
$File = "$Path\IP-$Date.txt"
$FileHtml = "$Path2\IP-$Date.htm"
$FileXML = "$Path\IP-$Date.xlsx"
$FileHTMLWeb = "$PathWeb\IP-$date.htm"
######################################
#Define error actions.
$erroractionpreference = "SilentlyContinue"
###########################################
#Since the script used COM objects it will need the following 2 folders:
#(32Bit)
MD "C:\Windows\System32\config\systemprofile\Dektop" -force
MD "C:\Windows\System32\config\systemprofile\AppData\Local\Microsoft\Windows\Temporary Internet" -force
#(64Bit)
MD "C:\Windows\SysWOW64\config\systemprofile\Desktop" -force
MD "C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Microsoft\Windows\Temporary Internet" -force
#Once successfull the script will run without a problem if scheduled.
cls
(gc $File) | ? {$_.trim() -ne "" } | set-content $File
$IPCount = (gc $File)
$IPCount = $IPCount.count
write "$IPCount unique IP addresses detected."
#Define error actions.
$erroractionpreference = "SilentlyContinue"
#Get content from given IP list.
$colComputers = #(gc $File | sort |Select -unique)
$SourceCount = $colComputers.Count
write "$SourceCount IP's detected."
Function Set-KnownIPs{
Param([Object]$DNSLookupObject)
Switch($DNSLookupObject){
{$_.Source -Match "(108.162.254|141.101.(?:104|105)|199.27.128|173.245(?:53|52|51))"}{$_.HostName = "CloudFlare, Inc."}
{$_.Source -Match "(64.18.[0-18])"}{$_.HostName = "Google, Inc."}
{$_.Source -Match "(192.168|127.0.0)"}{$_.HostName = "Internal Infrastructure"}
}
$DNSLookupObject
}
#Get DNS Results
$Progress=1
$DNSResults = $colComputers | %{
Write-Progress -Activity "Creating a usable 'Blocked IP' list ($Progress/$sourcecount)" -PercentComplete ($Progress/$sourceCount*100) -Status "Please stand by"
try {
($dnsresult = [System.Net.DNS]::GetHostEntry($_))
}
catch {
$dnsresult = "Fail"
}
Set-KnownIPs -DNSLookupObject ([PSCustomObject][Ordered]#{
Source=$_.ToUpper()
HostName=$(if(!([string]::IsNullOrEmpty($dnsresult.HostName))){$dnsresult.HostName})
IPAddress=$(if(!([string]::IsNullOrEmpty($dnsresult.AddressList))){$dnsresult.AddressList[0].ToString()})
})
$Progress++
}
$Keywords = #("Google","Cloudflare","Cloud","Ping",
"Easy-Voyage","McAfee","Pingdom","Panopta","Scoot","Uniglobe",
"Internal")
$Filter = "($(($Keywords|%{[RegEx]::Escape($_)}) -join "|"))"
$DNSLookupFailed = $DNSResults |
?{[string]::IsNullOrEmpty($_.HostName) -and !($_ -match $filter)}
$DNSWithKeyword = $DNSResults |
?{$_ -match $Filter}
$DNSNoKeyword = $DNSResults |
?{!($_.HostName -match $Filter) -and !([string]::IsNullOrEmpty($_.IPAddress))}
#$count = ($DNSResults|?{$_ -match $filter}).count
$count = $SourceCount
#####################
#start Excel.
$a = New-Object -comobject Excel.Application
# set interactive to false so nothing from excel is shown.
$a.DisplayAlerts = $False
$a.ScreenUpdating = $True
$a.Visible = $True
$a.UserControl = $True
$a.Interactive = $True
###########################
#Create sheets in Excel.
$b = $a.Workbooks.Add()
$c = $b.Worksheets.Item(1)
$c.Activate() | Out-Null
#Create a Title for the first worksheet and adjust the font
$c.Cells.Item(1,1)= "Blocked IP's $Date"
$c.Cells.Item(1,1).Font.ColorIndex = 55
$c.Cells.Item(1,1).Font.Color = 8210719
$c.Cells.Item((3+$DNSWithKeyword.Count+1),1) = "IP's not in whitelist"
$c.Cells.Item((3+$DNSWithKeyword.Count+1),1).Font.ColorIndex = 55
$c.Cells.Item((3+$DNSWithKeyword.Count+1),1).Font.Color = 8210719
$c.Cells.Item((3+$DNSWithKeyword.Count+$DNSNoKeyword.Count+3),1)= "IP's without DNS return"
$c.Cells.Item((3+$DNSWithKeyword.Count+$DNSNoKeyword.Count+3),1).Font.ColorIndex = 55
$c.Cells.Item((3+$DNSWithKeyword.Count+$DNSNoKeyword.Count+3),1).Font.Color = 8210719
#######################################
$range = $c.Range("a1","e1")
$range.Style = 'Title'
$range.Select()
$range.MergeCells = $true
$range.VerticalAlignment = -4108
################################
$Linkedin = "https://www.linkedin.com/profile/view?id=96981180" #Look me up! :D
#Define row to be used for linkedin link.
$CounterRow = $Count+5
######################
#Define subjects.
$c.Name = "Blocked IP's ($Date)"
$c.Cells.Item(2,1) = "Given IP"
$c.Cells.Item(2,2) = "Resolved DNS"
$c.Cells.Item(2,3) = "Returned IP"
$c.Cells.Item(2,5) = "$Company"
$c.Cells.Item((3+$DNSWithKeyword.Count+$DNSNoKeyword.Count+$DNSLookupFailed.Count+5),1) = "Created by"
########################################
$link = "http://www.$Company"
$link2 = "$Linkedin"
$r = $c.Range("E2")
[void]$c.Hyperlinks.Add($r, $link)
$r = $c.Range("A$(3+$DNSWithKeyword.Count+$DNSNoKeyword.Count+$DNSLookupFailed.Count+5)")
[void]$c.Hyperlinks.Add($r, $link2)
###################################
#Define cell formatting from subjects.
$c.Range("A2:E2").Interior.ColorIndex = 6
$c.Range("A2:E2").font.size = 13
$c.Range("A2:E2").Font.ColorIndex = 1
$c.Range("A2:E2").Font.Bold = $True
###################################
#Define the usedrange, excluding header and footer rows
$KeyRange = $c.Range("A3:c$(3+$DNSWithKeyword.Count)")
$NoKeyRange = $c.Range("A$(3+$DNSWithKeyword.Count+2):c$(3+$DNSWithKeyword.Count+$DNSNoKeyword.Count+2)")
$NoDNSRange = $c.Range("A$(3+$DNSWithKeyword.Count+$DNSNoKeyword.Count+4):c$(3+$DNSWithKeyword.Count+$DNSNoKeyword.Count+$DNSLookupFailed.Count+4)")
$SheetRange = $c.Range("A3:e$(4+$DNSWithKeyword.Count+$DNSNoKeyword.Count+$DNSLookupFailed.Count+4)")
$Investigate = $c.Range("c$(3+$DNSWithKeyword.Count+$DNSNoKeyword.Count+4):c$(3+$DNSWithKeyword.Count+$DNSNoKeyword.Count+$DNSLookupFailed.Count+4)")
################################
#Set background color for the IP list.
$SheetRange.interior.colorindex = 6
$KeyRange.interior.colorindex = 4
$NoKeyRange.interior.colorindex = 15
$NoDNSRange.interior.colorindex = 8
####################################
#Populate data into spreadsheet
$DNSWithKeyword | Select Source, HostName, IPAddress | Sort HostName -Descending |
ConvertTo-Csv -Delimiter "`t" -NoTypeInformation |
Select -Skip 1 | Clip
$c.Paste($KeyRange,$false)
$DNSNoKeyword | Select Source, HostName, IPAddress | Sort HostName -Descending |
ConvertTo-Csv -Delimiter "`t" -NoTypeInformation |
Select -Skip 1 | Clip
$c.Paste($NoKeyRange,$false)
$DNSLookupFailed | Select Source, HostName, IPAddress | sort Source -Descending|
ConvertTo-Csv -Delimiter "`t" -NoTypeInformation |
Select -Skip 1 | Clip
$c.Paste($NoDNSRange,$false)
############################
ForEach($Cell in $Investigate){
If([String]::IsNullOrWhitespace($Cell.value2)){
$Cell.Item($_) = "N/A"
[void]$cell.Hyperlinks.Add($Cell)
}
}
###########################################################################
#Define borders here.
$xlOpenXMLWorkbook = 51
$xlAutomatic=-4105
$xlBottom = -4107
$xlCenter = -4108
$xlRight = -4152
$xlContext = -5002
$xlContinuous=1
$xlDiagonalDown=5
$xlDiagonalUp=6
$xlEdgeBottom=9
$xlEdgeLeft=7
$xlEdgeRight=10
$xlEdgeTop=8
$xlInsideHorizontal=12
$xlInsideVertical=11
$xlNone=-4142
$xlThin=2
#########
$selection = $c.range("A2:C$(1+$DNSResults.Count-9)")
$selection.select() |out-null
$selection.HorizontalAlignment = $xlRight
$selection.VerticalAlignment = $xlBottom
$selection.WrapText = $false
$selection.Orientation = 0
$selection.AddIndent = $false
$selection.IndentLevel = 0
$selection.ShrinkToFit = $false
$selection.ReadingOrder = $xlContext
$selection.MergeCells = $false
$selection.Borders.Item($xlInsideHorizontal).Weight = $xlThin
#############################################################
#Define the usedrange for autofitting.
$d = $c.UsedRange
#################
#Make everything fit in it's cell.
$d.EntireColumn.AutoFit() | Out-Null
####################################
$c.usedrange | Where{$_.Value2 -match "(\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b)"} |
ForEach{$IPLink = "http://who.is/whois-ip/ip-address/$($Matches[1])";[void]$c.Hyperlinks.Add($_, $IPLink)}
#Define html code for Excel save to .htm.
$xlExcelHTML = 44
#################
#Save final result as an .xlsx file.
$b.SaveAs("$FileXML")
#####################
#Save final result as a .htm file
$b.SaveAs("$FileHTML",$xlExcelHTML)
###################################
In powershell 5.1 you can use
Resolve-DnsName
How does one access data imported from a CSV file by using dynamic note property names? That is, one doesn't know the colunm names beforehand. They do match a pattern and are extracted from the CSV file when the script runs.
As for an example, consider a CSV file:
"Header 1","Header A","Header 3","Header B"
0,0,0,0
1,2,3,4
5,6,7,8
I'd like to extract only columns that end with a letter. To do this, I read the header row and extract names with a regex like so,
$reader = new-object IO.StreamReader("C:\tmp\data.csv")
$line = $reader.ReadLine()
$headers = #()
$line.Split(",") | % {
$m = [regex]::match($_, '("Header [A-Z]")')
if($m.Success) { $headers += $m.value } }
This will get all the column names I care about:
"Header A"
"Header B"
Now, to access a CSV file I import it like so,
$csvData = import-csv "C:\tmp\data.csv"
Import-CSV will create a custom object that has properties as per the header row. One can access the fields by NoteProperty names like so,
$csvData | % { $_."Header A" } # Works fine
This obviously requires one to know the column name in advance. I'd like to use colunn names I extracted and stored into the $headers. How would I do that?
Some things I've tried so far
$csvData | % { $_.$headers[0] } # Error: Cannot index into a null array.
$csvData | % { $np = $headers[0]; $_.$np } # Doesn't print anything.
$csvData | % { $_.$($headers[0]) } # Doesn't print anything.
I could change the script like so it will write another a script that does know the column names. Is that my only solution?
I think you want this:
[string[]]$headers = $csvdata | gm -MemberType "noteproperty" |
?{ $_.Name -match "Header [a-zA-Z]$"} |
select -expand Name
$csvdata | select $headers
Choose the headers that match the condition (in this case, ones ending with characters) and then get the csv data for those headers.
the first thing ( and the only one... sorry) that came in my mind is:
$csvData | % { $_.$(( $csvData | gm | ? { $_.membertype -eq "noteproperty"} )[0].name) }
for get the first's column values and
$csvData | % { $_.$(( $csvData | gm | ? { $_.membertype -eq "noteproperty"} )[1].name) }
for second column and so on....
is this what you need?
you can use custom script to parse csv manually:
$content = Get-Content "C:\tmp\data.csv"
$header = $content | Select -first 1
$columns = $header.Split(",")
$indexes = #()
for($i; $i -lt $columns.Count;$i++)
{
# to verify whether string end with letter matches this regex: "[A-Za-z]$"
if ($column[$i] -match "[A-Za-z]$")
{
$indexes += $i
}
}
$outputFile = "C:\tmp\outdata.csv"
Remove-Item $outputFile -ea 0
foreach ($line in $content)
{
$output = ""
$rowcol = $line.Split(",")
[string]::Join(",", ($indexes | foreach { $rowcol[$_] })) | Add-Content $outputFile
}