Interesting bit about building a string with a delimiter and then removing the final delimiter. I will have to look and see how that works for me! I didn't say Chatgpt was efficient. It has potential, but I would definitely not rely on it. It needs to be constantly checked and repeatedly uses coding that is not supported by Kixtart!

OMG - I have just tested your line
$aArray = Function(args..)

and found the root of all my sorrows! I have just checked with Chatgpt and it also at one point along the dialogue said to do that, but I did not see it or understand at the time. It had got me completely on the wrong track! You are absolutely right. There is nothing wrong with the actual functions themselves!

I can see why I got this horribly wrong. All my coding in my scripts to date is in the format

Function(args). I have never done it like below:
$Variable = Function(args..). Didn't even know that was supported!

This is the first time (since using Kixtart) that I have ever used an array! Never needed to use an array before! I will have to investigate to see if arrays are the only exception to the rule of Functions (args) in the context that I use them in, so I don't make this mistake in the future with something else.

Irritating thing is that Chatgpt did at some point raise this as the solution, but only after extensive editing of the function itself. Which is what makes using Chatgpt such a double edged sword! I have learnt a lot about coding since using Chatgpt, but it obviously is not ready to teach me coding!

Never occurred to me that the problem was with code calling the function itself!

Thank you for picking up what the actual problem was! At least I now have a much better understanding of WinNT, LDAP and arrays due to spending 2 days on the issue lol!

Much appreciated. Everything is working. Tested all UDFS and it does what it says on the tin!