- This topic has 2 replies, 2 voices, and was last updated 3 months, 1 week ago by
October 9, 2020 at 5:35 am #262049ParticipantTopics: 2Replies: 1Points: -22Rank: Member
Hi Guys. i have couple of queries with PS + SQL. I have installed SQLserver module for my implementation.
Case1 (Machine in domain): When i tried running Read-SqlTableData -ServerInstance $Instance -DatabaseName $Database -TableName $Table -SchemaName “dbo” it worked fine. But when i tried with credential Read-SqlTableData -ServerInstance $Instance -DatabaseName $Database -TableName $Table -SchemaName “dbo” -Credential Get-Credential it fails to connect. I am passing the Windows credential with which i have logged in. Could you help me understand why this is failing?
Case 2 (Machine in workgroup) – In this case how to access SQL server which is in domain using SQL authentication through PS?
October 12, 2020 at 6:05 pm #262796ParticipantTopics: 8Replies: 16Points: 74Rank: Member
-Credential parameter works with SQL authenication in SqlServer module. If you’re attempting to pass with different windows credentials, it fails.
You may want to check other opensource powershell modules like dbatools which accepts both Windows + Sql auth credentials
- This reply was modified 3 months, 2 weeks ago by Harsha.
October 19, 2020 at 12:03 pm #264440ParticipantTopics: 2Replies: 1Points: -22Rank: Member
Hi, Thanks for the reply. I was able to fix it. For some strange reason it wasnt working when i was running from ISE.
I have another query. When i run : Get-SqlDatabase -ServerInstance $Instance -Credential $cred
I am only able to see master and tempdb databases. Actually its not displaying my database ie,”CDW”. I am able to connect to “CDW” database from Microsoft SQL server management studio with the same $cred credentials. Could you tell me why i am not able to see database other than master and tempdb. Is it is because of access issue could you tell me what privilege is required.
- The topic ‘Connect to SQL server instance with credentials’ is closed to new replies.