HiNeed the output of the results to a comma / semi colon / pipe delimited format.Function RunningSQLServices{[CmdletBinding()] Param ( [Parameter(Position=0,Mandatory=$true)][string]$filepath #Enter filename containing server names with single quotes , [Parameter(Position=1,Mandatory=$true)][string]$outfile #Enter path with single quotes (The file will be recreated if you use the same output file.) )Process{ $result=@() ForEach ($objitem in get-content $filepath) { $result += $objitem |out-file $outfile $result += get-service -ComputerName $objitem -displayname *SQL*| Where-Object {$_.status -eq "Running"}| Select-Object Machinename, Status,Name,DisplayName | format-table -auto -wrap -force } #$result | export-csv $outfile -Delimiter "|" -NoTypeInformation$result | out-file $outfile#$result | Export-Csv -Path 'C:\service_status1.txt' -Delimiter ';' –notype#$result |export-csv -delimiter "$" -path $outfile}}## This is the way to trying to convert. But no luck.$path = 'C:\service_status1.txt'$outPath = $path -replace ".txt",".csv"Get-Content -path $path | ForEach-Object {$_ -replace "\s",";" } | Out-File -filepath $outPath
↧