There are lots of examples all over the web on how to do this. A quick search using you favorite engine, using your posts' heading would give you a decent list on the topic. Even searching directly on this site, would give you a decent list.
For example:
Connect to SQL Server Database from PowerShell
I have looked around online for a while now and found many similar
problems but for some reason I can't seem to get this working.
I am just trying to connect to a SQL server database and output the
query results to a file - See PowerShell script below. What I am
uncertain about is how to integrate the User ID and Password into the
connection string.
Connect to SQL Server Database from PowerShell
Powershell - User Mapping SQL Server 2012
I am trying to script User Mapping for different Login accounts. I
have scripted the creation of users and individual server roles, but I
can't figure out how to set User Mapping with Powershell, I will also
need to set the Database Role membership, in Particular,
db_backupoperator
Powershell - User Mapping SQL Server 2012
Connect to SQL Server via Windows PowerShell with SQL Server
authentication
Problem In previous tips on Windows PowerShell with SQL Server, you've
seen how you can use Windows PowerShell and SMO to administer SQL
Server databases. Most of the examples have used Windows
authentication to connect to SQL Server. How can I connect to SQL
Server via Windows PowerShell using mixed mode authentication?
https://www.mssqltips.com/sqlservertip/1947/connect-to-sql-server-via-windows-powershell-with-sql-server-authentication/
SQL Server: Change the Login Password using PowerShell
Here’s a quick Article detailing a PowerShell script that can be used
to change the password for a SQL Server Login.
https://social.technet.microsoft.com/wiki/contents/articles/22767.sql-server-change-the-login-password-using-powershell/rss.aspx