Posts Tagged: PowerShell

MySQL connection with Powershell

Posted by & filed under , .

Here is the script that establishing a connection to the Mysql database with ‘select statement’ Param( [Parameter( Mandatory = $true, ParameterSetName = ”, ValueFromPipeline = $true)] [string]$Query ) $ConnectionString=”This is your connection string” Try { [void][System.Reflection.Assembly]::LoadWithPartialName(“MySql.Data”) $Con = New-Object MySql.Data.MySqlClient.MySqlConnection $Con.ConnectionString = $ConnectionString $Con.Open() $MySqlCommand= New-Object MySql.Data.MySqlClient.MySqlCommand($Query, $Con) $DataAdapter = New-Object MySql.Data.MySqlClient.MySqlDataAdapter($MySqlCommand) $DataSet = New-Object […]

How to run .cs file with powershell

Posted by & filed under .

It is so easy. First, lets put our c# code into a powershell string. Here is the example. $exampleCode=@’using System; using System; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.IO; using System.Windows.Media.Imaging; using System.Xml;