Skip to main content
1 vote
1 answer
54 views

I am trying to run invoke-sqlcmd in powershell in my laptop, getting error related to certificate

i got a new laptop from my organization, whenever i try to run invoke-sqlcmd i used to get an error saying that the server certificate is not trusted, i had to keep "-TrustServerCertificate" ...
cross_handle's user avatar
1 vote
2 answers
311 views

Has there been a recent change to Invoke-Sqlcmd that break it, and if so what's the fix?

I have a script that runs in an Azure DevOps pipeline that was working up until this morning (18/6/2025). I previous had to upgrade a MS Graph Access token breaking change here The Azure DevOps ...
Aiden Dipple's user avatar
3 votes
0 answers
145 views

How to Display Entire Error Message from Invoke-Sqlcmd

Here is the relevant code: $params = @{ Query = $query ServerInstance = $serverInstance Database = $database Verbose = $true ...
Adam Winter's user avatar
  • 1,992
1 vote
3 answers
127 views

Powershell converting bit values to Boolean in result set

I have an issue whereby a query called via Invoke-SQLCmd returns a certain set of results. For some columns the value is a 0 or 1 of BIT data type. The results instead come back as False or True in ...
Rami Aboulissane's user avatar
0 votes
0 answers
25 views

invoke-sqlcmd on multiple server - limitation is that PS run with Windows admin only and SQL runs with DB admin account only

I have been trying so hard to use PowerShell command invoke-sqlcmd to run simple SQL queries on multiple SQL servers, where some are default instances servername and some are named instances ...
Jawid's user avatar
  • 1
0 votes
1 answer
79 views

Invoke-sqlCmd output CSV for each stored procedure results

I am trying to get multiple stored procedures, each out outputting certain results with varying column names. I have managed to get the script to parse through each query however it just lumps all the ...
Rami Aboulissane's user avatar
0 votes
0 answers
277 views

Invoke-Sqlcmd is not available from within powershell script

I am not able from within .ps1 script call function Invoke-Sqlcmd. This script is: Install-Module -Name SqlServer Invoke-Sqlcmd -ServerInstance "SQLSERVER\" -Database "MYDB" -Query ...
LDonSOvrfw's user avatar
1 vote
1 answer
310 views

Invoke-SqlCmd vs SqlCmd

I have to tried to find the source code for Invoke-SqlCmd, but to no luck. My question is: Does Invoke-SqlCmd use sqlcmd.exe behind the scenes? Additionally, are there any SQL Server commands ...
Iftikhar Ali's user avatar
0 votes
0 answers
123 views

Using Invoke-sqlcmd occasionally outputs a blank csv file

I'm fairly new to using powershell so bear with me. My goal is to query a database over our network and save the file output of the query as a csv on the local machine. The query works as intended but ...
Daniel Blanton's user avatar
0 votes
0 answers
103 views

Access is Denied while running SQL bulk insert query

I am trying to run command Invoke-Sqlcmd via powershell using gma account and trying to insert into table through bulk insert. Job is running on Windows server and SQL server is remote. Command ...
Kartik M's user avatar
  • 109
0 votes
1 answer
694 views

Working with the new SQL Server PS module and -Encrypt parameter

With the introduction of the new SQL Server PS module, Microsoft has made the -Encrypt parameter mandatory for Invoke-Sqlcmd cmdlet. Invoke-Sqlcmd -ServerInstance $server -query $sql -Encrypt Optional ...
RaviLobo's user avatar
  • 538
0 votes
1 answer
473 views

Invoke-sqlcmd raises exception "Keyword not supported: 'authentication'" while connecting to Azure SQL DB

I receive the following exception while connecting Azure SQLDB with Invoke-SQLCMD PowerShell command. $conn = 'Server=tcp:MyServer.database.windows.net,1433;Database=MyDB;Authentication=Active ...
RaviLobo's user avatar
  • 538
0 votes
0 answers
44 views

JSON data in SQL Server table column getting truncated on extraction [duplicate]

We are using SQL Server 2019. We have databases in SQL Server. In one column (Events) of a table, the data is stored in JSON format and data type of that column is - nvarchar(MAX). Every night, a job ...
NewbieHere's user avatar
0 votes
1 answer
999 views

Unable to connect to Azure SQL Database using Invoke-Sqlcmd in PowerShell

I'm currently facing an issue with connecting to an Azure SQL Database using PowerShell's Invoke-Sqlcmd cmdlet. I am able to successfully connect to the database using sqlcmd (Version 18.2.0001.1 ...
Shimii's user avatar
  • 25
0 votes
0 answers
116 views

Handling output of invoke-sqlcmd in PowerShell

I have a sql query that outputs its result as a bit. I am trying to capture this output in a variable in PowerShell, and then use it in an IF/ELSE to decide the next step to run. The sql query is ...
supergdify's user avatar

15 30 50 per page
1
2 3 4 5
12