"Reprint" PowerShell set up century interconnect Office365 nested group send permissions

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.