-
Notifications
You must be signed in to change notification settings - Fork 14
/
Disable-HiddenGroups.ps1
84 lines (55 loc) · 2.65 KB
/
Disable-HiddenGroups.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<#
.SYNOPSIS
Disable-HiddenGroups changes the switch -HiddenFromExchangeClientsEnabled to false for all Office365 Groups created in Microsoft Teams
This cmdlet was designed for users. As such no switches need to be defined. Running the cmdlet will not prompt the user for input.
The user will need to be granted permissions to change this setting and also be the groups owner. Or you can jsut do it for them.
.DESCRIPTION
A recent Microsoft Office Update has changed -HiddenFromExchangeClientsEnabled from default false to default true.
This cmdlet can be uesd to change -HiddenFromExchangeClientsEnabled to false for all newly created groups
.NOTES
Author: Robert H. Osborne
Alias: tobor
Contact: [email protected]
.LINK
https://osbornepro.com
https://writeups.osbornepro.com
https://btpssecpack.osbornepro.com
https://github.com/tobor88
https://gitlab.com/tobor88
https://www.powershellgallery.com/profiles/tobor
https://www.linkedin.com/in/roberthosborne/
https://www.credly.com/users/roberthosborne/badges
https://www.hackthebox.eu/profile/52286
.EXAMPLE
Disable-HiddenGroups
#>
Function Disable-HiddenGroups {
[CmdletBinding()]
Param()
BEGIN {
If (Get-PSSession | Where-Object -Property ConfigurationName -like 'Microsoft.Exchange') {
Remove-PSSession -Session *
} # End if
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $cred -Authentication Basic -AllowRedirection
Write-Verbose 'Importing Exchange Online Cmdlets'
Import-PSSession $Session
Clear-Host
} # End BEGIN
PROCESS {
Try {
Write-Verbose "Obtaining list of all Office365 Team Display Names `n Please wait......."
$UnifiedGroup = Get-UnifiedGroup | Select-Object -Property DisplayName
} # End Try
Catch {
Write-Warning "Issue running the command. Ensure you are connected to the internet. `nVerify you have permission to execute Get-UnifiedGroup cmdlet. `nVerify you are entering your password correctly."
$Error[0]
} # End Catch
} # End PROCESS
END {
Write-Verbose "Successfully found your Office365 Groups. `nIssuing Command to prevent hiding Office 365 groups from Outlook."
ForEach ($G in $Group) {
Set-UnifiedGroup -Identity $G.Name -HiddenFromExchangeClientsEnabled:$False -ErrorAction SilentlyContinue
Write-Verbose "$G `nCompleted"
} # End Foreach
} # End END
} # End Function Disable-HiddenGroups