This should work actually.
Is there a special reason why you use the old and pretty much obsolete Quest cmdlets instead of the AD cmdlets from Microsoft? And is there a special reason why you don’t indent your code accordingly? That would make it easier to read and to understand and to debug.
Unfortunately I have to use the Quest Cmdlets as dictated by my boss because it logs who has touched AD objects with ActiveRoles Server. Apologies about the code indentation - it is actually indented properly (I use VS Code which formats automatically) but for some reason when I put the code between the pre tags it does not format it right.
I thought it should work too but for some reason it isn’t.
[/pre]
every time you loop through the the foreach in your original example, you over-write $object.
you don’t actually do the export-csv until after you have completed iterating through the for-each loop.
See above, I’v you put your export line up one level so it sits inside of the foreach loop, so you will actually export the contents of $object each time you enumerate a user id.
Now an unexpected consequence of your code will be if you pass in an invalid user id.
You will have very unexpected results if that occurs.
every time you loop through the the foreach in your original example, you over-write $object.
you don’t actually do the export-csv until after you have completed iterating through the for-each loop.
See above, I’v you put your export line up one level so it sits inside of the foreach loop, so you will actually export the contents of $object each time you enumerate a user id.
Now an unexpected consequence of your code will be if you pass in an invalid user id.
You will have very unexpected results if that occurs.[/quote]
Thanks very much for your reply, is there a better way I can do this to avoid the unexpected behaviour if an invalid name is passed?