The Invoke-Sqlcmd module is a PowerShell module that will allow you to execute T-SQL statements.
In order to install the Invoke-Sqlcmd module, you will need to open PowerShell.
Before installing the module, you need to set the execution policy to “AllSigned”. To do this, type the following command:
1 Set-ExecutionPolicy -ExecutionPolicy AllSigned -Scope Process
Using the -Scope Process flag will limit the execution policy change to the current PowerShell window that is open.
We can now install the Invoke-Sqlcmd module by typing the following command:
1 Install-Module -Name SQLServer
Here are additional links regarding the Invoke-Sqlcmd:
https://docs.microsoft.com/en-us/sql/powershell/download-sql-server-ps-module?view=sql-server-ver16