2020 年 6 月 3 日

IT Skills 波林

Polin WEI – 資訊工作者的技術手札

如何利用 PowerShell 隱藏 Office 365 群組

1 min read
雲彩

如何利用 PowerShell 隱藏 Office 365 群組

  • 首先使用系統管理員身分啟動 PowerShell,並連線至 Exchange Online
$UserCredential = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

Import-PSSession $Session -DisableNameChecking
  • 隱藏指定的O365群組
Set-UnifiedGroup -Identity [email protected] -HiddenFromAddressListsEnabled $true
  • 隱藏 類型是私人的O365群組
$Groups = Get-UnifiedGroup -ResultSize Unlimited | ? {$_.AccessType -like "Private"}
Foreach ($Group in $Groups) {Set-UnifiedGroup -Identity $Group.Name -HiddenFromAddressListsEnabled $true}
  • 隱藏 類型是公開的O365群組
$Groups = Get-UnifiedGroup -ResultSize Unlimited | ? {$_.AccessType -like "Public"}
Foreach ($Group in $Groups) {Set-UnifiedGroup -Identity $Group.Name -HiddenFromAddressListsEnabled $true}
  • 隱藏所有O365群組
$Groups = Get-UnifiedGroup -ResultSize Unlimited 
Foreach ($Group in $Groups) {Set-UnifiedGroup -Identity $Group.Name -HiddenFromAddressListsEnabled $true}
  • 隱藏Teams 的O365群組
$Groups = Get-UnifiedGroup -ResultSize Unlimited | ? {$_.ResourceProvisioningOptions -like "Team"}
Foreach ($Group in $Groups) {Set-UnifiedGroup -Identity $Group.Name -HiddenFromAddressListsEnabled $true}
  • 隱藏Teams 的私人O365群組
$Groups = Get-UnifiedGroup -ResultSize Unlimited | ? {$_.ResourceProvisioningOptions -like "Team"} | ? {$_.AccessType -like "Private"}
Foreach ($Group in $Groups) {Set-UnifiedGroup -Identity $Group.Name -HiddenFromAddressListsEnabled $true}

 

Copyright © All rights reserved. | Newsphere by AF themes.