Stemming from this post: Powershell: Specify file path as variable
I am using Invoke-Sqlcmd in a PowerShell script to execute the following sql query:
update [$Db_name].[dbo].[$BatchTable]
set [$Db_name].[dbo].[$BatchTable].Wave = 'Wave1'
from [$Db_name].[dbo].[$BatchTable]
inner join OPENROWSET(BULK '$FILEPATH',
FORMATFILE= 'C:\import.xml') AS a
on ([$Db_name].[dbo].[$BatchTable].Name= a.Name) and
([$Db_name].[dbo].[$BatchTable].Domain = a.Domain)
I am logging a few messages but I am wondering how I can log any errors when the update query is run as well as when a match is found (optimally display a count successful and unsuccessful matches)