Hello,
I am still learning all of the ins and outs of PowerShell so if this is an easy answer I apologize for not knowing it. My task is to create a separate csv file contacting the email contact information from specific Distribution Groups.
I know how to export the list to a single file one a time taking the input from the screen and exporting the information to a pre-named csv file I have used the append command to place all the information in one file and then break out the information in Excel. Or by adding the group name to the export command doing one group at a time. What I cannot figure out is how to create the each individual csv file based on what I key in at the screen. I keep getting different errors.
What I would like to eventually get to is read in a csv file that has the list of Distribution Groups that I need the information from. I would like to export each group into its own file. I realize that I probably need to create a loop that retrieves the distribution group name from a file on at a time. But since I cannot get the file created by name from what I key in, I cannot export each group in its own named file.
Here is what I have:
<!-- [if gte mso 9]>--> <!-- [if gte mso 9]>--> Normal 0 false false false EN-US X-NONE X-NONE <!-- [if gte mso 9]>--> <!-- [if gte mso 10]>--> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;} $GroupName=Read-Host "Enter the name of Group for Which you want to Export Contacts" $memberof=get-adgroup $GroupName |select -expandproperty distinguishedname Get-ADObject -Filter 'objectclass -eq "contact" -and memberof -eq $memberof' -properties *|select name,mail,@{e={"$($_.memberof)"};l="Member Of"} | Export-CSV c:\temp\DL Owners\test.csv -notype -Encoding UTF8