จัดการสิทธิ์ของกล่องจดหมายโดยใช้ PowerShell | ออฟฟิศ 365
ในบทความปัจจุบัน เราจะตรวจสอบวิธีใช้คำสั่ง PowerShell สำหรับจัดการสิทธิ์กล่องจดหมายการเข้าถึงแบบเต็มในสภาพแวดล้อม Exchange Online
เชื่อมต่อกับ Exchange Online PowerShell
เพื่อให้สามารถเรียกใช้คำสั่ง PowerShell ที่ระบุในบทความปัจจุบัน คุณจะต้องเชื่อมต่อกับ Exchange Online PowerShell
เริ่ม Windows PowerShell ในฐานะผู้ดูแลระบบ และเรียกใช้ cmdlet Connect-ExchangeOnline
Connect-ExchangeOnlineสิทธิ์กล่องจดหมาย
สิทธิ์ของกล่องจดหมายประกอบด้วยสองประเภท:
- สิทธิ์การเข้าถึงแบบเต็ม - ช่วยให้ผู้รับรายอื่นสามารถดูเนื้อหาในกล่องจดหมายทั้งหมดได้
- การอนุญาตให้ส่งอีเมลโดยใช้ชื่อผู้รับอื่น (“ส่งเป็น ” และ “ส่งในนามของ ” )
สิทธิ์กล่องจดหมายบางส่วนสามารถกำหนดได้โดยผู้ใช้เอง (โดยใช้อินเทอร์เฟซ Outlook หรือ OWA) และสิทธิ์ในการส่งอีเมลโดยใช้ชื่อผู้รับอื่นสามารถจัดสรรได้โดยใช้อินเทอร์เฟซ PowerShell เท่านั้น
ข้อได้เปรียบที่สำคัญของการใช้ PowerShell ในการจัดการสิทธิ์ของกล่องจดหมายคือผู้ดูแลระบบสามารถสร้างการตั้งค่าที่จำเป็นสำหรับผู้ใช้จากระยะไกล (ช่วยเหลือผู้ใช้และป้องกันการกำหนดค่าที่พลาด) และใช้พลังของ PowerShell เพื่อดำเนินการคำสั่งในโหมดเป็นกลุ่ม (ดำเนินการการตั้งค่าการกำหนดค่าสำหรับ มากกว่าหนึ่งเมลบ็อกซ์)
สิทธิ์กล่องจดหมาย PowerShell สั่งโครงสร้างพื้นฐาน
โครงสร้างพื้นฐานของคำสั่งสิทธิ์กล่องจดหมาย PowerShell ถูกเขียนโดยใช้ไวยากรณ์ต่อไปนี้:
ในตัวอย่างของเรา เราต้องการเปิดใช้งาน Alice เพื่อรับสิทธิ์การเข้าถึงแบบเต็มเพื่อฟังกล่องจดหมายของผู้จัดการ พารามิเตอร์ -Identity เกี่ยวข้องกับผู้ใช้ที่ต้องการ "แบ่งปัน" กล่องจดหมายของเขา (ให้ตัวเลือกแก่ผู้ใช้รายอื่นในการเข้าถึงเนื้อหาในกล่องจดหมายของเขา) และพารามิเตอร์ -User แสดงถึงผู้ใช้ที่จะสามารถเข้าถึงกล่องจดหมายได้
1. กำหนดสิทธิ์กล่องจดหมาย
1.1 - กำหนดสิทธิ์ "การเข้าถึงแบบเต็ม" สำหรับกล่องจดหมาย
ไวยากรณ์คำสั่ง PowerShell:
Add-MailboxPermission <Identity> -User <Identity> -AccessRights FullAccess -InheritanceType Allตัวอย่างคำสั่ง PowerShell:
Add-MailboxPermission John -User Suzan -AccessRights FullAccess -InheritanceType All1.2 - กำหนดสิทธิ์ "ส่งเป็น" สำหรับกล่องจดหมาย
ไวยากรณ์คำสั่ง PowerShell:
Add-RecipientPermission <Identity> -AccessRights SendAs -Trustee <Identity>ตัวอย่างคำสั่ง PowerShell:
Add-RecipientPermission John -AccessRights SendAs -Trustee Suzanเพื่อหลีกเลี่ยงความจำเป็นในการยืนยัน เราสามารถเพิ่มตัวเลือก: “-Confirm:$False ”
Add-RecipientPermission John -Trustee Suzan -AccessRights SendAs -Confirm:$False1.3 - กำหนดสิทธิ์ "ส่งเป็น" สำหรับกล่องจดหมายทั้งหมด (BulkMode)
ไวยากรณ์คำสั่ง PowerShell:
$MBXS = Get-Recipient -RecipientType UserMailbox
ForEach ($MBX in $MBXS) {
Add-RecipientPermission $MBX.name -AccessRights SendAs -Trustee <User Principal Name> -Confirm:$False
}
Get-RecipientPermission | Where { ($_.Trustee -ne 'nt authority\self') -and ($_.Trustee -ne 'Null sid') } }ตัวอย่างคำสั่ง PowerShell:
$MBXS = Get-Recipient -RecipientType UserMailbox
ForEach ($MBX in $MBXS) {
Add-RecipientPermission $MBX.name -AccessRights SendAs -Trustee John@o365info.com -Confirm:$False
}
Get-RecipientPermission | Where { ($_.Trustee -ne 'nt authority\self') -and ($_.Trustee -ne 'Null sid') } }1.4 - กำหนดสิทธิ์ “ส่งเป็น” สำหรับผู้รับสำหรับสมาชิกแต่ละคนในกลุ่มการแจกจ่าย
ไวยากรณ์คำสั่ง PowerShell:
$DL = Get-DistributionGroupMember
Foreach ($item in $DL) {
Add-RecipientPermission $item.name -AccessRights SendAs -Trustee <Identity> -Confirm:$False
}ตัวอย่างคำสั่ง PowerShell:
$DL = Get-DistributionGroupMember DL-01
Foreach ($item in $DL) {
Add-RecipientPermission $item.name -AccessRights SendAs -Trustee Suzan -Confirm:$False
}1.5 - กำหนดสิทธิ์ "ส่งเป็น" สำหรับสมาชิกแต่ละคนในกลุ่มการแจกจ่ายสำหรับผู้รับเฉพาะ
ไวยากรณ์คำสั่ง PowerShell:
$DL = Get-DistributionGroupMember
Foreach ($item in $DL) {
Add-RecipientPermission <Identity> -AccessRights SendAs -Trustee $item.name -Confirm:$False
}ตัวอย่างคำสั่ง PowerShell:
$DL = Get-DistributionGroupMember DL-01
Foreach ($item in $DL) {
Add-RecipientPermission Suzan -AccessRights SendAs -Trustee $item.name -Confirm:$False
}1.6 - กำหนดสิทธิ์ "ส่งในนามของ" สำหรับกล่องจดหมาย
ไวยากรณ์คำสั่ง PowerShell:
Set-Mailbox <Identity> -GrantSendOnBehalfTo <Identity>ตัวอย่างคำสั่ง PowerShell:
Set-Mailbox -Identity John -GrantSendOnBehalfTo Suzan1.7 - กำหนดสิทธิ์ “การเข้าถึงแบบเต็ม” สำหรับกล่องจดหมายทั้งหมด (BulkMode)
ไวยากรณ์คำสั่ง PowerShell:
Get-Mailbox -ResultSize unlimited -Filter {RecipientTypeDetails -eq 'UserMailbox'} | Add-MailboxPermission -User <Identity> -AccessRights FullAccess -InheritanceType Allตัวอย่างคำสั่ง PowerShell:
Get-Mailbox -ResultSize unlimited -Filter {RecipientTypeDetails -eq 'UserMailbox'} | Add-MailboxPermission -User John -AccessRights FullAccess -InheritanceType All2. กำหนดสิทธิ์การเข้าถึงแบบเต็มและ AutoMap
2.1 - กำหนดสิทธิ์ “การเข้าถึงแบบเต็ม” ให้กับกลุ่มการแจกจ่าย + AutoMap
ไวยากรณ์คำสั่ง PowerShell:
$DL = Get-DistributionGroupMember <Distribution Group> | Select-Object -ExpandProperty Name
ForEach ($Member in $DL ) {
Add-MailboxPermission -Identity <Identity> -User $S -AccessRights FullAccess -InheritanceType All
}ตัวอย่างคำสั่ง PowerShell:
$DL = Get-DistributionGroupMember "Assistants Group" | Select-Object -ExpandProperty Name
ForEach ($Member in $DL ) {
Add-MailboxPermission -Identity "FL1 Room1" -User $S -AccessRights FullAccess -InheritanceType All
}2.2 - กำหนดสิทธิ์ "การเข้าถึงแบบเต็ม" สำหรับกล่องจดหมายทั้งหมด (BulkMode) และปิดใช้งาน AutoMap
ไวยากรณ์คำสั่ง PowerShell:
Get-Mailbox -ResultSize unlimited -Filter {RecipientTypeDetails -eq 'UserMailbox'} | Add-Mailboxpermission -User <Identity> -AccessRights FullAccess -InheritanceType All -Automapping $Falseตัวอย่างคำสั่ง PowerShell:
Get-Mailbox -ResultSize unlimited -Filter {RecipientTypeDetails -eq 'UserMailbox'} | Add-Mailboxpermission -User John -AccessRights FullAccess -InheritanceType All -Automapping $False2.3 - กำหนดสิทธิ์ "การเข้าถึงแบบเต็ม" สำหรับผู้ใช้เฉพาะและปิดใช้งาน AutoMap
ไวยากรณ์คำสั่ง PowerShell:
Add-MailboxPermission <Identity> -User <Identity> -AccessRights FullAccess -InheritanceType All -AutoMapping $Falseตัวอย่างคำสั่ง PowerShell:
Add-MailboxPermission John -User Suzan -AccessRights FullAccess -InheritanceType All -AutoMapping $False3. แสดงการอนุญาตสำหรับกล่องจดหมาย
3.1 - แสดงสิทธิ์ “การเข้าถึงแบบเต็ม” สำหรับกล่องจดหมาย
ไวยากรณ์คำสั่ง PowerShell:
Get-MailboxPermission <Identity>ตัวอย่างคำสั่ง PowerShell:
Get-MailboxPermission Johnเพื่อปรับปรุงคุณภาพของผลลัพธ์ เราสามารถใช้พารามิเตอร์ PowerShell เพิ่มเติมที่จะ "ล้าง" ข้อมูลที่ไม่จำเป็น:
Get-MailboxPermission John | Where { ($_.IsInherited -eq $False) -and -not ($_.User -like “NT AUTHORITY\SELF”) } | Select Identity,user,AccessRights3.2 - แสดงการอนุญาต “ส่งเป็น” สำหรับกล่องจดหมาย
ไวยากรณ์คำสั่ง PowerShell:
Get-RecipientPermission <Identity>ตัวอย่างคำสั่ง PowerShell:
Get-RecipientPermission Johnเพื่อปรับปรุงคุณภาพของผลลัพธ์ เราสามารถใช้พารามิเตอร์ PowerShell เพิ่มเติมที่จะ "ล้าง" ข้อมูลที่ไม่จำเป็น:
Get-RecipientPermission John | Where { ($_.IsInherited -eq $False) -and -not ($_.Trustee -like “NT AUTHORITY\SELF”) } | Select Trustee,AccessControlType,AccessRights3.3 - แสดงสิทธิ์ “ส่งในนามของ” สำหรับกล่องจดหมาย
ไวยากรณ์คำสั่ง PowerShell:
Get-Mailbox <Identity>ตัวอย่างคำสั่ง PowerShell:
Get-Mailbox Johnเพื่อปรับปรุงคุณภาพของผลลัพธ์ เราสามารถใช้พารามิเตอร์ PowerShell เพิ่มเติมที่จะ "ล้าง" ข้อมูลที่ไม่จำเป็น:
Get-RecipientPermission John | Where { ($_.IsInherited -eq $False) -and -not ($_.Trustee -like “NT AUTHORITY\SELF”) } | Select Trustee, AccessControlType, AccessRights3.4 - ดู “สิทธิ์ส่งเป็น” ทั้งหมดที่คุณได้กำหนดค่าไว้ในองค์กรของคุณ
ไวยากรณ์คำสั่ง PowerShell:
Get-RecipientPermission | where {($_.Trustee -ne 'nt authority\self') -and ($_.Trustee -ne 'Null sid')} | select Identity,Trustee,AccessRights3.5 - แสดงรายการผู้รับที่มีสิทธิ์การเข้าถึงแบบเต็มสำหรับผู้รับรายอื่น
ไวยากรณ์คำสั่ง PowerShell:
$a = Get-Mailbox $a |Get-MailboxPermission | Where { ($_.IsInherited -eq $False) -and -not ($_.User -like “NT AUTHORITY\SELF”) -and -not ($_.User -like '*Discovery Management*') } | Select Identity, user, AccessRights4. เพิกถอนสิทธิ์
4.1 - เพิกถอนสิทธิ์ "การเข้าถึงแบบเต็ม"
ไวยากรณ์คำสั่ง PowerShell:
Remove-MailboxPermission <Identity> -User <Identity> -AccessRights FullAccessตัวอย่างคำสั่ง PowerShell:
Remove-MailboxPermission John -User Suzan -AccessRights FullAccessเพื่อหลีกเลี่ยงความจำเป็นในการยืนยัน เราสามารถเพิ่มตัวเลือก: “-Confirm:$False ”
Remove-MailboxPermission John -User Suzan -AccessRights FullAccess -Confirm:$False4.2 - เพิกถอนสิทธิ์ "ส่งเป็น"
ไวยากรณ์คำสั่ง PowerShell:
Remove-RecipientPermission <Identity> -AccessRights SendAs -Trustee <Identity>ตัวอย่างคำสั่ง PowerShell:
Remove-RecipientPermission John -AccessRights SendAs -Trustee Suzanเพื่อหลีกเลี่ยงความจำเป็นในการยืนยัน เราสามารถเพิ่มตัวเลือก: “-Confirm:$False ”
Remove-RecipientPermission John -AccessRights SendAs -Trustee Suzan -Confirm:$False
