Skip to content

Commit

Permalink
Merge pull request #5667 from NikCharlebois/MeetingInsights
Browse files Browse the repository at this point in the history
O365SearchAndIntelligence -Added SPN support and Meeting insights
  • Loading branch information
NikCharlebois authored Jan 23, 2025
2 parents 3012725 + 72b89b8 commit 3207476
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 21 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change log for Microsoft365DSC

# UNRELEASED

* FabricAdminTenantSettings
* Fix titles that have a zero length whitespace character.
* O365SearchAndIntelligenceConfigurations
* Added support for Meeting Insights settings.
* Added support for Service Principal authentication.

# 1.25.122.1

* AADConditionalAccessPolicy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2140,7 +2140,7 @@ function Get-M365DSCFabricTenantSettingObject
$values = @{
settingName = $Setting.settingName
enabled = [Boolean]$Setting.enabled
title = $Setting.title
title = ($Setting.title -creplace '\P{IsBasicLatin}')
}
if (-not [System.String]::IsNullOrEmpty($Setting.canSpecifySecurityGroups))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ function Get-TargetResource
[System.String]
$ItemInsightsDisabledForGroup,

[Parameter()]
[System.Boolean]
$MeetingInsightsIsEnabledInOrganization,

[Parameter()]
[System.Boolean]
$PersonInsightsIsEnabledInOrganization,
Expand All @@ -29,11 +33,34 @@ function Get-TargetResource
[System.Management.Automation.PSCredential]
$Credential,

[Parameter()]
[System.String]
$ApplicationId,

[Parameter()]
[System.String]
$TenantId,

[Parameter()]
[System.String]
$CertificateThumbprint,

[Parameter()]
[System.String]
$CertificatePath,

[Parameter()]
[System.Management.Automation.PSCredential]
$CertificatePassword,

[Parameter()]
[System.String[]]
$AccessTokens
)

$ConnectionMode = New-M365DSCConnection -Workload 'ExchangeOnline' `
-InboundParameters $PSBoundParameters

$ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' `
-InboundParameters $PSBoundParameters

Expand Down Expand Up @@ -87,14 +114,21 @@ function Get-TargetResource
}
}

$MeetingInsightsResponse = Get-MeetingInsightsSettings
$MeetingInsightsValue = [Boolean]::Parse($MeetingInsightsResponse.Split(':')[1].Trim())

return @{
IsSingleInstance = 'Yes'
ItemInsightsIsEnabledInOrganization = $ItemInsights.IsEnabledInOrganization
ItemInsightsDisabledForGroup = $itemInsightsDisabledForGroupValue
PersonInsightsIsEnabledInOrganization = $PersonInsights.IsEnabledInOrganization
PersonInsightsDisabledForGroup = $PersonInsightsDisabledForGroupValue
Credential = $Credential
AccessTokens = $AccessTokens
IsSingleInstance = 'Yes'
ItemInsightsIsEnabledInOrganization = $ItemInsights.IsEnabledInOrganization
ItemInsightsDisabledForGroup = $itemInsightsDisabledForGroupValue
MeetingInsightsIsEnabledInOrganization = $MeetingInsightsValue
PersonInsightsIsEnabledInOrganization = $PersonInsights.IsEnabledInOrganization
PersonInsightsDisabledForGroup = $PersonInsightsDisabledForGroupValue
Credential = $Credential
ApplicationId = $ApplicationId
TenantId = $TenantId
CertificateThumbprint = $CertificateThumbprint
AccessTokens = $AccessTokens
}
}
catch
Expand Down Expand Up @@ -127,6 +161,10 @@ function Set-TargetResource
[System.String]
$ItemInsightsDisabledForGroup,

[Parameter()]
[System.Boolean]
$MeetingInsightsIsEnabledInOrganization,

[Parameter()]
[System.Boolean]
$PersonInsightsIsEnabledInOrganization,
Expand All @@ -139,6 +177,26 @@ function Set-TargetResource
[System.Management.Automation.PSCredential]
$Credential,

[Parameter()]
[System.String]
$ApplicationId,

[Parameter()]
[System.String]
$TenantId,

[Parameter()]
[System.String]
$CertificateThumbprint,

[Parameter()]
[System.String]
$CertificatePath,

[Parameter()]
[System.Management.Automation.PSCredential]
$CertificatePassword,

[Parameter()]
[System.String[]]
$AccessTokens
Expand Down Expand Up @@ -219,6 +277,11 @@ function Set-TargetResource
Write-Verbose -Message 'Updating settings for Person Insights'
Update-MgBetaOrganizationSettingPersonInsight @PersonInsightsUpdateParams | Out-Null
#endregion

if ($null -ne $MeetingInsightsIsEnabledInOrganization)
{
Set-MeetingInsightsSettings -Enabled $MeetingInsightsIsEnabledInOrganization | Out-Null
}
}

function Test-TargetResource
Expand All @@ -240,6 +303,10 @@ function Test-TargetResource
[System.String]
$ItemInsightsDisabledForGroup,

[Parameter()]
[System.Boolean]
$MeetingInsightsIsEnabledInOrganization,

[Parameter()]
[System.Boolean]
$PersonInsightsIsEnabledInOrganization,
Expand All @@ -252,6 +319,26 @@ function Test-TargetResource
[System.Management.Automation.PSCredential]
$Credential,

[Parameter()]
[System.String]
$ApplicationId,

[Parameter()]
[System.String]
$TenantId,

[Parameter()]
[System.String]
$CertificateThumbprint,

[Parameter()]
[System.String]
$CertificatePath,

[Parameter()]
[System.Management.Automation.PSCredential]
$CertificatePassword,

[Parameter()]
[System.String[]]
$AccessTokens
Expand Down Expand Up @@ -296,6 +383,26 @@ function Export-TargetResource
[System.Management.Automation.PSCredential]
$Credential,

[Parameter()]
[System.String]
$ApplicationId,

[Parameter()]
[System.String]
$TenantId,

[Parameter()]
[System.String]
$CertificateThumbprint,

[Parameter()]
[System.String]
$CertificatePath,

[Parameter()]
[System.Management.Automation.PSCredential]
$CertificatePassword,

[Parameter()]
[System.String[]]
$AccessTokens
Expand Down Expand Up @@ -323,9 +430,12 @@ function Export-TargetResource
}

$Params = @{
IsSingleInstance = 'Yes'
Credential = $Credential
AccessTokens = $AccessTokens
IsSingleInstance = 'Yes'
Credential = $Credential
AccessTokens = $AccessTokens
ApplicationId = $ApplicationId
TenantId = $TenantId
CertificateThumbprint = $CertificateThumbprint
}

$Results = Get-TargetResource @Params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ class MSFT_O365SearchAndIntelligenceConfigurations : OMI_BaseResource
[Key, Description("Specifies the resource is a single instance, the value must be 'Yes'"), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance;
[Write, Description("Specifies whether or not Item Insights should be available for the organization.")] Boolean ItemInsightsIsEnabledInOrganization;
[Write, Description("Specifies a single Azure AD Group for which Item Insights needs to be disabled.")] String ItemInsightsDisabledForGroup;
[Write, Description("Specifies whether or not Meeting Insights should be available for the organization.")] Boolean MeetingInsightsIsEnabledInOrganization;
[Write, Description("Specifies whether or not Person Insights should be available for the organization.")] Boolean PersonInsightsIsEnabledInOrganization;
[Write, Description("Specifies a single Azure AD Group for which Person Insights needs to be disabled.")] String PersonInsightsDisabledForGroup;
[Write, Description("Credentials of the Global Admin"), EmbeddedInstance("MSFT_Credential")] string Credential;
[Write, Description("Id of the Azure Active Directory application to authenticate with.")] String ApplicationId;
[Write, Description("Id of the Azure Active Directory tenant used for authentication.")] String TenantId;
[Write, Description("Thumbprint of the Azure Active Directory application's authentication certificate to use for authentication.")] String CertificateThumbprint;
[Write, Description("Username can be made up to anything but password will be used for CertificatePassword"), EmbeddedInstance("MSFT_Credential")] String CertificatePassword;
[Write, Description("Path to certificate used in service principal usually a PFX file.")] String CertificatePath;
[Write, Description("Access token used for authentication.")] String AccessTokens[];
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ Configuration Example
{
O365SearchAndIntelligenceConfigurations 'SearchAndIntelligenceConfigurations'
{
Credential = $Credscredential;
IsSingleInstance = "Yes";
ItemInsightsIsEnabledInOrganization = $False;
ItemInsightsDisabledForGroup = "TestGroup"
PersonInsightsIsEnabledInOrganization = $True;
Credential = $Credscredential;
IsSingleInstance = "Yes";
ItemInsightsIsEnabledInOrganization = $False;
MeetingInsightsIsEnabledInOrganization = $True;
ItemInsightsDisabledForGroup = "TestGroup"
PersonInsightsIsEnabledInOrganization = $True;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,25 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
DisplayName = "TestGroup"
}
}

Mock -CommandName Get-MeetingInsightsSettings -MockWith {
return "Meeting Insights setting enabled: false"
}

Mock -CommandName Set-MeetingInsightsSettings -MockWith {
}
}

# Test contexts
Context -Name 'When Org Settings are already in the Desired State' -Fixture {
BeforeAll {
$testParams = @{
IsSingleInstance = 'Yes'
ItemInsightsIsEnabledInOrganization = $True;
ItemInsightsDisabledForGroup = "TestGroup"
PersonInsightsIsEnabledInOrganization = $True;
Credential = $Credential
IsSingleInstance = 'Yes'
ItemInsightsIsEnabledInOrganization = $True;
ItemInsightsDisabledForGroup = "TestGroup"
PersonInsightsIsEnabledInOrganization = $True;
MeetingInsightsIsEnabledInOrganization = $false;
Credential = $Credential
}

Mock -CommandName Get-MgBetaOrganizationSettingItemInsight -MockWith {
Expand Down
15 changes: 15 additions & 0 deletions Tests/Unit/Stubs/Microsoft365.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,21 @@ function Disable-AzSubscription
#endregion

# region ExchangeOnlineManagement

function Get-MeetingInsightsSettings
{
[CmdletBinding()]
param(
)
}

function Set-MeetingInsightsSettings
{
[CmdletBinding()]
param(
)
}

function Get-EmailTenantSettings
{
[CmdletBinding()]
Expand Down

0 comments on commit 3207476

Please sign in to comment.