Skip to content

Commit

Permalink
New cmds
Browse files Browse the repository at this point in the history
  • Loading branch information
PrzemyslawKlys committed Sep 13, 2021
1 parent 9af2d6c commit 73f356b
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Public/Set-O365AzureGroupM365.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
function Set-O365AzureGroupM365 {
<#
.SYNOPSIS
Enables or Disables Microsoft 365 Groups - "Users can create Microsoft 365 groups in Azure portals, API or PowerShell"
.DESCRIPTION
Enables or Disables Microsoft 365 Groups - "Users can create Microsoft 365 groups in Azure portals, API or PowerShell"
.PARAMETER Headers
Authorization header as created by Connect-O365Admin. If not provided the function will try to fetch it from the current execution context.
.PARAMETER AllowedToCreateM365Groups
Enables or disables "Users can create Microsoft 365 groups in Azure portals, API or PowerShell"
.EXAMPLE
Set-O365AzureGroupM365 -Verbose -AllowedToCreateM365Groups $true -WhatIf
.NOTES
https://portal.azure.com/#blade/Microsoft_AAD_IAM/GroupsManagementMenuBlade/General
#>
[cmdletbinding(SupportsShouldProcess)]
param(
[alias('Authorization')][System.Collections.IDictionary] $Headers,
[parameter(Mandatory)][bool] $AllowedToCreateM365Groups
)
$CurrentSettings = Get-O365AzureGroupNamingPolicy -NoTranslation -Headers $Headers
if ($CurrentSettings.id) {
$Uri ="https://graph.microsoft.com/beta/settings/$($CurrentSettings.id)"
[Array] $Values = foreach ($Policy in $CurrentSettings.values) {
if ($Policy.Name -eq 'EnableGroupCreation') {
[PSCustomObject] @{
name = 'EnableGroupCreation'
value = $AllowedToCreateM365Groups.ToString()
}
} else {
$Policy
}
}
$Body = @{
values = $Values
}
$null = Invoke-O365Admin -Uri $Uri -Headers $Headers -Method PATCH -Body $Body
}
}
32 changes: 32 additions & 0 deletions Public/Set-O365AzureGroupNamingPolicy.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
function Set-O365AzureGroupNamingPolicy {
<#
.SYNOPSIS
Sets new prefix/suffix for M365 groups naming policy.
.DESCRIPTION
Sets new prefix/suffix for M365 groups naming policy. The Microsoft 365 groups naming policy allows you to add a specific prefix and/or suffix to the group name and alias of any Microsoft 365 group created by users. For example: <Finance> <group> <Seattle>
.PARAMETER Headers
Authorization header as created by Connect-O365Admin. If not provided the function will try to fetch it from the current execution context.
.PARAMETER Prefix
Sets or updates the prefix for the group naming policy. One can use words or predefined prefixes.
.PARAMETER Suffix
Sets or updates the suffix for the group naming policy. One can use words or predefined suffixes.
.PARAMETER RemoveNamingConvention
Removes the prefix and suffix from the group naming policy.
.EXAMPLE
Set-O365AzureGroupNamingPolicy -Verbose -Prefix 'O365' -Suffix 'Uops', [Company], 'test' -WhatIf
.EXAMPLE
Set-O365AzureGroupNamingPolicy -Verbose -Prefix 'O365' -Suffix '' -WhatIf
.EXAMPLE
Set-O365AzureGroupNamingPolicy -Verbose -RemoveNamingConvention -WhatIf
.NOTES
https://portal.azure.com/#blade/Microsoft_AAD_IAM/GroupsManagementMenuBlade/NamingPolicy
#>
[cmdletbinding(SupportsShouldProcess, DefaultParameterSetName = 'PrefixSuffix')]
param(
[alias('Authorization')][System.Collections.IDictionary] $Headers,
[Parameter(ParameterSetName = 'PrefixSuffix')][string[]] $Prefix,
[Parameter(ParameterSetName = 'PrefixSuffix')][string[]] $Suffix,
[Parameter(ParameterSetName = 'Remove')][switch] $RemoveNamingConvention
Expand Down

0 comments on commit 73f356b

Please sign in to comment.