Just a quickie note.

I needed to get some information about servers’ computer objects from AD. Simple query with some properties:

What started simple soon became more… complicated:

Somewhere along the way I had to query this from multiple domains using different credentials and finally export it into csv.

Every time I was adding new property or select-object property I had to do it in multiple places. Remember this started as an ad-hoc script, not polished function. Eventually I moved all properties and select-object into variables.

Thing to remember - select-object requires separate elements, not single string.

Now, this is a way better to read through:


Final touch

Also moved all domains into an array: