1Start-transcript". \set-groupsendpermisionlog.txt"- Force2 3 functionget-Dlmemberrecurse4 {5 $group=get-distributiongroupmember$args[0]-ResultSize Unlimited6 foreach($varTemp inch $group)7 {8 $varTemp9 if($varTemp. RecipientType-like "Mail*group")Ten { One $members+=$varTemp. Identity AGet-dlmemberrecurse$varTemp. Identity - } - } the return $members - } - - $CsvPath=". \set-groupsendpermisionlist.csv" + - $Users= Import-csv$CsvPath + A foreach($User inch $Users) at { - $groupname=$User. Group - $groupname - - if(! (Get-distributiongroup$groupname)) - { inEcho"Group not found" -}Else { toEcho"Group found" +Get-dlmemberrecurse$groupname| Where-object {$_. RecipientType-like "Mail*group"} | Select Name | Export-csv-notypeinformation-encoding Utf8-path. \set-Groupsendpermision.csv - $content=get-content-encoding Utf8-path. \set-groupsendpermision.csv | Select-skip 1 the $content=$content. Replace ("`"","") * #$content $ $dup=($content| measure-Object). CountPanax Notoginseng $dup -Echo----------------------------------------------- the $content=$content| Sort | get-Unique + #$content A $nodup=($content| measure-Object). Count the $nodup +Echo =============================================== - for($i= 1;$i -le $nodup;$i++) $ { $ $i -Echo 1 - if($nodup -eq1) the { - $Identity=$contentWuyi } the Else - { Wu $Identity=$content[$i-1] - } AboutEcho 2 $ $Identity -Echo 3 -(get-distributiongroup-identity$Identity). Acceptmessagesonlyfromsendersormembers -Echo 4 A #set-distributiongroup-identity $Identity-acceptmessagesonlyfromsendersormembers (Get-distributiongroup- Identity $Identity). Acceptmessagesonlyfromsendersormembers + "$Gmember")-bypasssecuritygroupmanagercheck +Echo ******************************* the } - } $Echo/////////////////////////////////////////////////////////////////////////////// the } the theget-pssession | remove-pssession theStop-transcript
CSV format
User,group
User1,group1
User1,group2
User1,group3
User2,group1
User3,group3
http://www.smallrascal.cn/smallrascal/article.asp?id=2082
"Reprint" PowerShell set up century interconnect Office365 nested group send permissions