April 7, 2016

Create ODBC Connection with Powershell

Filed under: Tips — donrsh @ 8:55 am

Create ODBC Connection with Powershell.

	 Created on:   	2016-04-07 
	 Created by:   	Arash Nabi
	 Email: 	    arash@nabi.nu 


		Create ODBC Connection
		Create ODBC Connection
		Provide a SQLserver with instance name. Ex SQLserver\InstanceName
	.PARAMETER Databases
		A description of the Databases parameter.
		Data Source Name type
	.PARAMETER Platform
		X86 or X64 platform
	.PARAMETER DriverName
		An ODBC driver allows ODBC-enabled programs to get information from ODBC data sources.
		A description of the Name parameter.
		PS C:\>  Create-ODBC -SQLserver SQLserver\InstanceName -Databases DBname -DsnType System -Platform 64-bit -Verbose
		Additional information about the function.
function Create-ODBC
		[ValidateSet('System', 'User')]
		[ValidateSet('64-bit', '32-bit')]
		foreach ($Database in $Databases)
			Add-OdbcDsn -Name $Database -DriverName "SQL Server Native Client 11.0" -DsnType $DsnType -Platform $Platform -SetPropertyValue @("Server=$SQLserver", "Trusted_Connection=Yes", "Database=$Database") -ErrorAction SilentlyContinue -PassThru
	catch [System.IO.IOException] {
		Write-Verbose -Message "End of script"


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: