Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Sql Server connectivity and script execution using Powershell

$
0
0

Iam designing a powershell script that can execute some sql scripts that is placed inside a folder. Actually this must be done remotely. I am able to connect to the particular server remotely using 

$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server = servername; Database = dbname; Integrated Security = True" 
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand

But when I use 

[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
$server = new-object ("Microsoft.SqlServer.Management.Smo.Server")"SQL01\Instancename" Iam getting an error related with SMO dll. Since I am trying to execute remotely, in this machine SQL Server is not installed. So,SMO.dll is not available. How can I achieve my aim??Please someone help me on this..

Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>