Showing results for 
Search instead for 
Did you mean: 
ale_leme New Member
New Member

Streaming from SQL Server

When ai try run this script, it return error message.


$SqlServer = 'GRANITOAON';
$SqlDatabase = 'DWPago';

$SqlConnectionString = 'Data Source={0};Initial Catalog={1};Integrated Security=SSPI' -f $SqlServer, $SqlDatabase;
$SqlQuery = "select a.QuantidadeTransações as TransacoesMes, a.ValorTransacionado as ValorTransacoesMes, b.QuantidadeTransações as TransacoesDia, b.ValorTransacionado as ValorTransacoesDia, c.Data as Data, c.TransacoesUltimoMin as TransacoesMinuto, c.TempoProcessamentoBD as TempoProcessamentoBD, c.TempoProcessamentoSocket as TempoProcessamentoSocket, c.TempoProcessamentoHSM as TempoProcessamentoHSM from [vw_rt_transacoesmes] a, [vw_rt_transacoesdia] b, [vw_rt_processamentotransacao] c;";

$SqlCommand = New-Object -TypeName System.Data.SqlClient.SqlCommand;
$SqlCommand.CommandText = $SqlQuery;
$SqlConnection = New-Object -TypeName System.Data.SqlClient.SqlConnection -ArgumentList $SqlConnectionString;
$SqlCommand.Connection = $SqlConnection;

$SqlDataReader = $SqlCommand.ExecuteReader();

##you would find your own endpoint in the Power BI service
$endpoint = ""

#Fetch data and write out to files
while ($SqlDataReader.Read()) {
$payload = @{
"Transações Mês" =$SqlDataReader['TransacoesMes']
"Valor Transacionado Mês" =$SqlDataReader['ValorTransacoesMes']
"Transações Dia" =$SqlDataReader['TransacoesDia']
"Valor Transacionado Dia" =$SqlDataReader['ValorTransacoesDia']
"Data" =$SqlDataReader['Data']
"Transações por minuto" =$SqlDataReader['TransacoesMinuto']
"Tempo Médio Procesamento BD" =$SqlDataReader['TempoProcessamentoBD']
"Tempo Médio Processamento Socket" =$SqlDataReader['TempoProcessamentoSocket']
"Tempo Médio Processamento HSM" =$SqlDataReader['TempoProcessamentoHSM']
Invoke-RestMethod -Method Post -Uri $endpoint -Body (ConvertTo-Json @($payload))





Invoke-RestMethod : The remote server returned an error: (404) Not Found.
At line:33 char:5
+ Invoke-RestMethod -Method Post -Uri $endpoint -Body (ConvertTo-Json @($paylo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Helpful resources

New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Kudoed Authors (Last 30 Days)