I have a value that I want to find and pull out of a database. I have everything I need in order to run this script except how to store the result in a variable and then write those results to a txt file
$CNumber = Invoke-Sqlcmd -query ("Select Cust From SY.CompanyCode") -ServerInstance $SQLInstance -Database $Database
Add-Content $Mobile $CNumber
When it writes the results in the text file it looks like this:
System.Data.DataRow
When I just run the Invoke-Sqlcmd and don't try to store it in a variable I can see the correct value. So I'm assuming once this query runs, I need to convert the results somehow?
Please and thank you.