Connect to SQL server instance with credentials

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?

-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

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.