RC2’s new [ADSI] type shortcut showed up without any methods, only properties, causing quite a bit of confusion, given that a lot of working scripts are now broken. Aruk Kumaravel, Windows PowerShell Development Manager, provided a little clarification in a posting at microsoft.public.windows.powershell. The part I still don’t understand is why they would even consider not exposing the methods via get-member…
I know that many of you are wondering about ADSI changes in RC2. I am currently in the process of writing a blog to explain the new ADSI support. People are wondering as to why methods are not showing up in GM. .Net DirectoryService Object is wrapper around the underlying AD com object. Based on the type of AD com object, it can have any number of interfaces like IADs, IADsContainer, IADsNameSpaces etc. .Net DirectoryService doesn’t expose all the functionality of the underlying AD object. That is the reason why DirectoryEntry object has property called NativeObject to access the underlying COM object. The Native COM object doesn’t have all the metadata to determine all the methods that it provides. Faced with this constraint, we chose a route similar to VBScript. When we decided to support AD Scripting, we wanted to make it as simple as possible but at the same time expose of the full functionality of AD. VBSCript provides this functionality with set of following methods alone
The above list of methods will allow you to do pretty much all ADSI scripting tasks. We thought of exposing these set of methods as part of Get-Member call but decided against it (In retrospect, maybe we should have exposed these). Not exposing the methods is what throws people off with the new ADSI support.
I had written some blog posts on using new ADSI support in the following blogs. Please take a look at it. I used ADAM to test these scripts
For Advanced script users, who are still interested in access to the DirectoryEntry object, it is available as PSBase property in the PSObject. People who are familiar with ADSI scripting with VBScript will find the transition much easier. If you are used to using DirectoryEntry object then the new changes would be disruptive to existing mental model.
I will look into some of the examples people have provided in the blog posts and convert few of this into new ADSI syntax and share it with you.
Aruk Kumaravel [MSFT]
Windows PowerShell Development Manager