Search

Index

Revindex Task Scheduler

Get connection string (PowerShell)

Last updated on 2015-03-25 1 mins. to read

You can get connection strings stored in your Web.config in PowerShell by issuing the following statement:


$connectionString = [DotNetNuke.Common.Utilities.Config]::GetConnectionString("SiteSqlServer")
$connection = New-Object System.Data.SqlClient.SqlConnection
$connection.ConnectionString = $connectionString
$command = $connection.CreateCommand()
$command.CommandText = "UPDATE table1 SET col1 = '1' WHERE col1 = '2'"
$connection.Open()
$command.ExecuteNonQuery()
$connection.Close()

Comments


Powered by Revindex Wiki