0

I wrote a function Get-oracleresultDa which have oracle connection properties.Through which I can query my DB.

But,the problem is which I try to export the data to the excel sheet it only returns the result of the second query i.e)no status and not no type

$results = Get-OracleResultDa -conString $connectionString -sqlString $query 
-Verbose
$results | SELECT no, type| Export-CSV "H:\Book2.csv" -Force
$rows++
$results1 = Get-OracleResultDa -conString $connectionString -sqlString 
$created -Verbose
$results1 | SELECT no, status| Export-CSV "H:\Book2.csv" -
NoTypeInformation

The below mentioned block was in the first 10 linesof the script

$file="H:\Book2.csv"
$excel = New-Object -ComObject excel.application
#Makes Excel Visable
$excel.Application.Visible = $true
$excel.DisplayAlerts = $false
#Creates Excel workBook
$book = $excel.Workbooks.Add()
#Adds worksheets

#gets the work sheet and Names it
$sheet = $book.Worksheets.Item(1)
$sheet.name = 'Created'
#Select a worksheet
$sheet.Activate() | Out-Null

I have few more query's which also as to be exported

0

1 Answer 1

1

If you use powershell 3.0 or better, you can use -Append modificator

$results = Get-OracleResultDa -conString $connectionString -sqlString $query 
-Verbose
$results | SELECT no, type| Export-CSV "H:\Book2.csv" -Force
$rows++



$results1 = Get-OracleResultDa -conString $connectionString -sqlString 
$created -Verbose
$results1 | SELECT no, status| Export-CSV "H:\Book2.csv" -
NoTypeInformation -Append
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.