Part 1 of 3
First, you need to install your "IBM iSeries Access for Windows" and make sure to include to load the ".NET provider". Then, you can use the IBM ADO.NET provider to connect to the i5 System.
The i5 System is a very secure environment and may need to discuss access permissions to the database(s) with your i5 Securiy Officer.
Now, the following simple sample will get you connected to the i5 System:
IBM ADO.NET connection
|
## Load GAC
[System.Reflection.Assembly]::LoadWithPartialName("System.Data")
[System.Reflection.Assembly]::LoadWithPartialName("IBM.Data.DB2.iSeries")
## Create strongly typed variables to hold your ID and Password
[string] $usr = 'YourUserID_here';
[string] $pwd = 'YourPassword_here';
## Build connection to i5
$i5Conn = New-Object System.Data.OleDb.OleDbConnection("Provider=IBMDA400;Data Source=IBMeServer;User ID=$usr;Password=$pwd;Initial Catalog=S1042B3A")
$i5Conn.Open();
|
Now, building a strongly typed variable served the purpose to hold the content as a full string. I had the experience that my userID had a $ and by not defining my variable string enougn then PowerShell was expecting another variable.
Here's the one line provider string: (in the sample is wrapped at the end of the line)
"
Provider=IBMDA400;Data Source=IBMeServer;User ID=$i5UID;Password=$i5PWD;Initial Catalog=S1042B3A"
Next, will use PowerShell to query an i5 table.