码迷,mamicode.com
首页 > 系统相关 > 详细

【转载】Powershell设置世纪互联Office365嵌套组发送权限

时间:2014-10-20 13:12:23      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   ar   for   sp   div   

 1 Start-Transcript ".\Set-GroupSendPermisionLog.txt" -Force
 2 
 3 function Get-DLMemberRecurse
 4 {
 5     $group=get-distributiongroupmember $args[0] -ResultSize unlimited
 6     foreach ($varTemp in $group)
 7     {
 8         $varTemp
 9         if ($varTemp.RecipientType -like "Mail*Group")
10         {
11             $members += $varTemp.Identity
12             Get-DLMemberRecurse $varTemp.Identity
13         }
14     }
15     return $members
16 }
17 
18 $CsvPath = ".\Set-GroupSendPermisionList.csv"
19 
20 $Users = import-csv $CsvPath
21 
22 foreach ($User in $Users) 
23 {
24     $groupname=$User.Group
25     $groupname
26 
27     if (!(get-distributiongroup $groupname))
28     {
29         echo "Group not found"
30     } else {
31         echo "Group found"
32         Get-DLMemberRecurse $groupname | where-Object {$_.RecipientType -like "Mail*Group"} | select name | export-csv -NoTypeInformation -Encoding utf8 -path .\Set-GroupSendPermision.csv
33         $content=Get-Content -Encoding utf8 -Path .\Set-GroupSendPermision.csv | Select -Skip 1
34         $content=$content.Replace("`"","")
35         #$content
36         $dup=($content | Measure-Object).count
37         $dup
38         echo -----------------------------------------------
39         $content=$content | sort | get-unique
40         #$content
41         $nodup=($content | Measure-Object).count
42         $nodup
43         echo ===============================================
44         for($i=1;$i -le $nodup;$i++)
45         {
46             $i
47             echo 1
48             if ($nodup -eq 1)
49             {
50             $Identity=$content
51             }
52             else
53             {
54             $Identity=$content[$i-1]
55             }
56             echo 2
57             $Identity
58             echo 3
59             (Get-DistributionGroup -identity $Identity).AcceptMessagesOnlyFromSendersOrMembers
60             echo 4
61             #Set-DistributionGroup -Identity $Identity -AcceptMessagesOnlyFromSendersOrMembers ((Get-DistributionGroup -identity $Identity).AcceptMessagesOnlyFromSendersOrMembers +"$Gmember") -BypassSecurityGroupManagerCheck
62             echo *******************************
63         }
64     }
65     echo ///////////////////////////////////////////////////////////////////////////////
66 }
67 
68 get-pssession | remove-pssession
69 Stop-Transcript


CSV格式
User,Group
user1,group1
user1,group2
user1,group3
user2,group1
user3,group3 

http://www.smallrascal.cn/smallrascal/article.asp?id=2082    

【转载】Powershell设置世纪互联Office365嵌套组发送权限

标签:style   blog   http   color   io   ar   for   sp   div   

原文地址:http://www.cnblogs.com/SignalTips/p/4026757.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!