How to login using SQL Server Management Object (SMO)
For windows authentication
SQL Authentication with hard coded password (note recommended)
Impersonate login as user using SQL authentication with secure credentials
So now we can repeatedly use those credentials
Hi, Thanks For your Script. How to select database, Drop, delete and update table etc.,
Please share those details
Hi Ramu,
You are welcome …
You can use invoke-sqlcmd command to run SQL statement against your instance …
$ConnStrDB = @{
‘Database’ = “yourdbname”
‘ServerInstance’ = “yourinstancename.database.windows.net”
‘Username’ = “yourusername”
‘Password’ = “yourpassword”
‘Query’ = “CREATE TABLE [dbo].[TestTAB](
[id] [int] IDENTITY(1,1) NOT NULL,
[Column01] [nvarchar](125) NULL
) ON [PRIMARY]
GO”
}
Invoke-Sqlcmd @ConnStrDB
You can as well user parameters and pass those values
param (
[string]$servername = “yourinstancename.database.windows.net”,
[string]$username = “yourusername”,
[string]$password = “yourpassword”,
[string]$dbname = “yourdbname”
)
Cheers