1

I'm a developer at a university in Chicago supporting Ellucian/Datatal Colleague on Unidata 7.2. We recently converted from Unidata on Unix to Windows Server and had a number of extract cron jobs that had to be converted to the new OS. During that conversion, I was introduced to the MS Windows Powershell Scripting Environment and have been using it to automate a lot of tasks that had been procedurally fragmented where the tasks were split up and executed asynchronously on different machines.

We are implementing the Ellucian Portal built on MS Sharepoint, and for that task we need to run a nightly job refreshing MS Active Directory attributes from our HR data. In order to do that I put together a Powershell script to take a flat file and update AD. However, the beauty of Powershell scripting is that you can work natively with .Net framework objects. I had developed a number of applications and utilities using VB UniObjects over the years and this seems to be a perfect opportunity to leverage the Powershell interface and build the extract step directly into the AD update script so the entire process can be executed as a single integrated application.

I've downloaded and installed the U2 toolkit for .Net from Rocket software but I've run into a snag in that the Powershell reference and instantiation syntax is different than any of the Visual Studio languages. Though I've been able to make some progress and have been able to establish a U2 ADO connection with the U2.Data.Client namespace, I am still having trouble instantiating the Native UniObjects U2.Data.Client.UO objects properly.

I'm sure that it just a simple issue with referencing the libraries correctly, but I've never actually worked with the .Net framework before, and I can't seem to find any authoritative examples of using the U2 .Net library in Powershell. This forum appears to be a great resource and the progress I've made is due to posts I've found here. If anyone has any thoughts or expertise in both U2 and Powershell I'd love to hear if you have an opinion on how to make the magic happen.

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130

2 Answers2

1

Thank you for asking this question. You can call very easily U2 Toolkit for .NET (U2NETDK) from Windows PowerShell. See the enclosed screen shot. I did the following:

  1. Install U2 Toolkit for .NET
  2. Refer the installed .NET U2NETDK assembly
  3. Create Connection Object
  4. Create Command Object
  5. Open Connection
  6. Execute ADO.NET Command ( SELECT FIRST_NAME, SURNAME FROM MEMBERS)
  7. Fetch Data. Write data on the PowerShell
  8. Close the Connection.

If you want to use UO.NET capability and you want to use read file, UniCommand, SelectList, then refer U2.Data.Client.UO.UniFile, U2.Data.Client.UO.UniCommand etc.

I hope this example will help other U2 .NET Users too.

enter image description here

See this example: http://blogs.technet.com/b/threekings/archive/2008/07/18/ado-net-in-powershell-update-sql-data-example-sample.aspx

Rajan Kumar
  • 718
  • 1
  • 4
  • 9
  • Rajan - thanks for that reply. I was able to test the ADO connection and it looks like it is connecting as expected though I am having a problem preparing the database using VSG (another topic) so I can't yet retrieve data. However, I still can't establish a reference or use the UniObjects native mode objects. The help for the UniObjects Session class shows the syntax: us = UniObjects.OpenSession("localhost","xxx","yyy","demo","udcs"); - but I can't seem to locate the proper way to reference the UniObjects library and the .OpenSession() method. Any ideas? – Rich Harrington Nov 12 '12 at 23:31
0

Thank you for trying U2NETDK' ADO.NET and windows PowerShell. For Native Access ( Uniobjects API), you do not need UODOTNET.DLL. We have embedded Uniobjects API in U2NETDK. So you will refer U2.Data.Client and U2.Data.Client.UO namespaces. See below the script and screen shot.

Add-Type -Path "C:\Program Files (x86)\Rocket Software\U2 Toolkit for .NET\U2 Database Provider\bin\.NETFramework\v2.0\U2.Data.Client.dll"

$Connection = New-Object U2.Data.Client.U2Connection

$Connection.ConnectionString = "Database=XDEMO;User ID=administrator;Password=pass;Server=9.72.199.235;Persist Security Info=True;ServerType=universe;AccessMode=Native"

$Connection.Open()

$Session = $Connection.UniSession

$UniSelectList  =$Session.CreateUniSelectList(2);

$UniFile  = $Session.CreateUniFile("PRODUCTS");
$UniSelectList.Select($UniFile);

while (!$UniSelectList.LastRecordRead)
{
$sRecID = $UniSelectList.Next();
write-host $sRecID
}
$Connection.Close()

enter image description here

Rajan Kumar
  • 718
  • 1
  • 4
  • 9