I will have another read up on the subject to see if I can understand it better. I also have the kixtart book "start to finish guide - scripting with kixtart", which I bought about 5 years ago. I will have another browse through that and see if can understand it better.

Just to clarify, my problem is not about understanding how UDF's work, although I realise that my UDF's are not correct in that I have not declared variables etc. My problem is more to do with understanding how to extract information from active directory and use that information in a script. This ADSI and WIMS stuff is where I go wrong. Thanks