Created
April 27, 2016 17:15
-
-
Save ATLPhenx/94ebad45769ca4bbea8ef48528f7fc10 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$connectionString = "Data Source=SQLSERVER;Initial Catalog=SYSINFO;Integrated Security=SSPI;" | |
#Find Connection information | |
#Gets system information | |
$os = Get-WmiInfo Win32_OperatingSystem | |
#loads the part of the .NET Framework that’s responsible for working with databases | |
[assembly.reflection]::loadwithpartialname('System.Data') | |
#Create new connection to database | |
$conn = New-Object System.Data.SqlClient.SqlConnection | |
$conn.ConnectionString = $connectionString | |
$conn.open() | |
#Creates sql command | |
$cmd = New-Object System.Data.SqlClient.SqlCommand | |
$cmd.connection = $conn | |
$cmd.commandtext = $query | |
#$cmd.executenonquery() | |
$queryResult = $cmd.ExecuteReader() | |
$conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment