rayrol
rayrol

Reputation: 1

Powershell tool ps2exe with SQL Query, login failed

I'm new on this site and a newby in programming Powershell.

I've made a Powershell script with forms. In the script I've made a connection string to a SQL server with integrated security (also tried credentials(domain and sql). In ISE all working fine, no problem. When I make a batchfile, all working fine. When I make an .exe of the ps1 file with ps2exe the script is running partly fine. The only thing is when I push a button to start a query, the script gives a message I "Login failed for user x".

Also tried invoke-sqlcmd, same problem. I've got all the rights to the server and databases.

Anyone got any idea or know if this is a bug in ps2exe?

     1. Function F_SQL_Query
     2. {
     3. param($VSQLServernaam, $VSQLDatabasenaam, $VSQLQueryString)
     4. $VdataAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
     5. $VconnString = "data source=$VSQLServernaam;initial catalog=$VSQLDatabasenaam;Integrated Security=sspi;trusted_connection=true;trustServerCertificate=True;"
     6. $VdataAdapter.SelectCommand = new-object System.Data.SqlClient.SqlCommand ($VSQLQueryString,$VconnString) 
     7. $VcommandBuilder = new-object System.Data.SqlClient.SqlCommandBuilder $VdataAdapter 
     8. $Vdt = New-Object System.Data.DataSet
     9. [void]$VdataAdapter.fill($Vdt)
    10. $Vdt.tables
    11. }

Upvotes: 0

Views: 189

Answers (0)

Related Questions