/\/\o\/\/ PowerShelled

This blog has moved to http://ThePowerShellGuy.com Greetings /\/\o\/\/
$AtomFeed = ("Atom.xml")
$PreviousItems = (" PowerShell Session video of Bruce Payette "," PowerShell : Active Directory Part 11 - moving - R... "," PowerShell : Learn about the HashTable Object and ... "," PowerShell : Setting SendAs permission in Exchange... "," PowerShell : Active Directory Part 10 (AD Browser)... "," PowerShell "," PowerShell : How Do I randomize a list, and remove... "," PowerShell : Can you do that less cryptic ? "," PowerShell : How can I tell whitch numbers are mis... "," PowerShell Active Directory Browser teaser "," ")

Tuesday, September 26, 2006

 


PowerShell : Using IronPython to Connect to AD and list children



  1. Iron Python is Released,

IronPython Release 1 P.0 Production

 

so here is an Hint  example how to start the IronPython CLI (ipy.exe) from powershell and to connect to the Active Directory RootDSE and to list its children.

PS C:\PowerShell> C:\IronPython-1.0\ipy.exe
IronPython 1.0.60816 on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
>>> import sys
>>> import clr
>>> import System
>>>
>>> clr.AddReferenceByPartialName("System.DirectoryServices")
>>> root = System.DirectoryServices.DirectoryEntry()
>>> for c in root.Children: print c.Name
...
CN=Builtin
CN=Computers
OU=Domain Controllers
CN=foo
CN=ForeignSecurityPrincipals
CN=Infrastructure
CN=Ken Myer
CN=LostAndFound
OU=MowOtherOU
OU=MowOu
CN=NewUs:::er0003
CN=NewUser0010
CN=NewUser0011
CN=NewUser0012
CN=NTDS Quotas
CN=Program Data
CN=System
CN=Users
>>> exit
'Use Ctrl-Z plus Return to exit'
>>> ^Z

*Edit* Importing NameSpaces, Cool !, but do not throw $$ around ;-)

 

import System.DirectoryServices
from System.DirectoryServices import *

root = DirectoryEntry()

>>> u = root.Children.Add("CN=fooBar","User")
>>> $u.name
Traceback (most recent call last):
SyntaxError: unexpected token bad character '$' (<stdin>, line 1)


>>> u.Name
'CN=fooBar'

Enjoy,

Greetings, /\/\o\/\/

Tags : Monad IronPython PowerShell




Comments: Post a Comment

Links to this post:

Create a Link



<< Home

Archives

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  

$Links = ("PowerShell RC1 Docs"," PowerShell RC1 X86"," PowerShell RC1 X64"," Monad GettingStarted guide"," Monad Progamming Guide"," Monad SDK"," Monad videos on Channel 9"," MSH Community Workspace"," scripts.readify.net "," MonadSource"," www.reskit.net"," PowerShell Blog"," Under The Stairs"," computerperformance powershell Home"," proudlyserving"," MSH on wikipedia"," MSHWiki Channel 9"," Keith Hill's Blog"," Precision Computing"," PowerShell for fun"," MSH Memo (Japanese)"," monadblog")

find-blog -about "PowerShell","Monad" | out-Technorati.
find-blog -contains "","" | out-Technorati.
Google
 
Web mow001.blogspot.com

This page is powered by Blogger. Isn't yours?