In last post about using IronPython from PowerShell : Using IronPython to Connect to AD and list children , I did just use the CLI.
In this post I will show how to Use IronPython from Powershell, by hosting it.
I first load the DLL's needed (copy them to PSHOME directory), and then just start using it.
The results are not lost you can still work with them and you can exchange variables very easy also see examples below :
# You can get back the results by using Evaluate
PS C:\PowerShell> $ipe.Evaluate('root.Children.Find("CN=FooBar")')
distinguishedName
-----------------
{CN=fooBar,DC=mow,DC=local}# Or you can get the variable
PS C:\PowerShell> $ipe.Globals["u"]
distinguishedName
-----------------
{CN=fooBar,DC=mow,DC=local}# Set a IronPython Variable
PS C:\PowerShell> $ipe.Globals['domain'] = [adsi]''
PS C:\PowerShell> $ipe.Evaluate('domain.Children.Find("CN=FooBar")')distinguishedName
-----------------
{CN=fooBar,DC=mow,DC=local}# and do a Dir (get-member) on that variable in IronPython
PS C:\PowerShell> $ipe.Evaluate('dir(domain)')
AuthenticationType
CanRaiseEvents
Children
Close
CommitChanges
As you see its very easy to mix IronPython and PowerShell parts.
Realy great !
Enjoy,
Greetings, /\/\o\/\/
Tags : Monad IronPython PowerShell
October 2005 November 2005 December 2005 January 2006 February 2006 March 2006 April 2006 May 2006 June 2006 July 2006 August 2006 September 2006 October 2006 November 2006 December 2006