I needed to fill in the email addresses for everyone using a factory. I did not want to figure out everyone’s email address and create the email configuration by hand so I went looking for some type of Active Directory tool to help me get the job done. I saw in the result that Google gave me a hit on PowerShell. I have always wanted to learn some PowerShell, this was just what I needed. So I installed PowerShell and the AD cmdlets.
Below is the command I used, all our devs are in a group.
get-QADGroupMember DevGroup | ForEach-object {’<user name=”‘ + $_.LogonName + ‘” group=”developer” address=”‘ + $_.Email + ‘”/>’}
I copied and pasted the output into the ccnetproject.xml.
Nice! I personally find myself using PowerShell and AD cmdlets for a lot of stuff for which I used to use Outlook, various self-service, portals, etc.: e.g. locating the group which I remember has ProgramManagers in the name, or updating my home phone number in the GAL (http://dmitrysotnikov.wordpress.com/2007/05/25/powershell-for-self-service/), or changing membership in a few DLs which I manage.
June 19th, 2007, at 10:02 am #I had to guess at what the property names where: LogonName and Email. How can I get a list of them? I did not see it in the documentation, am I blind?
Also is there a way to reflect on them and print them out in a table?
Property Name Property Value
June 19th, 2007, at 10:23 am #LogonName jflowers
Email jay.flowers@bogas.com
The trick I am using is outputting to Format-List which lists you all properties exposed to PowerShell, e.g.:
Get-QADUser “Dmitry Sotnikov” | Format-List
I know that some people are using Get-Member instead of Format-List so they get all .NET methods and properties too but I personally find this a bit messy.
Also, sometimes you would notice that you need an attribute which is in AD but is not exposed by PowerShell by default. In that case you can lookup the actual AD name somewhere on MSDN and use -IncludedProperties parameter to retrieve it.
I used that trick just yesterday to get the resultant password policy name:
Get-QADUser jlennon -IncludedProperties Msds-ResultantPSo | Format-Table Name, Msds-ResultantPSo
June 19th, 2007, at 10:35 am #