Here is my code, I am pulling user names, email addresses and a random password and would like to store these nicely in a CSV. How can I export to csv a custom property like my custom generated passwords while also exporting name and mail?
$pool = Get-ADUser -Filter * -SearchScope Subtree -SearchBase "OU=Test,OU=Users,OU=funny,DC=Corp,DC=funny,DC=com"
foreach ($user in $pool )
{
#MY NAME AND MAIL FUNCTION
$a = Get-ADUser $user -Properties name, mail
#MY PASSWORD FUNCTION
$password = {blah,blah,blah}
$password
}
$pool | Select-Object name,mail,$password | Export-Csv -path test.csv
How do I print the random password in the CSV along with name and mail?
Notes: I am doing this on AD. I would like the CSV to be neat as i will be parsing through it again using powershell. I am using Powershell 3.