Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various FIxes #1643

Merged
merged 3 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@

# 1.21.1222.1

* AADGroup
* Default to Unified type if no GroupTypes are provided;
FIXES #850
* EXOHostedCOntentFilterPolicy
* Fix for the MakeDefault property where it wasn't properly setting existing
policies to default.
FIXES #1635
* SPOSearchManagedProperty
* Fixed an issue with the Aliases retrieval;
* SPOUserProfileProperty
* Removed the Required key from the schema.mof file for Credential;
ISSUE #1632
* DEPENDENCIES
* Updated all Microsoft.Graph.* dependencies to version 1.9.1;
* MISC
* Fixed issue where running Export-M365DSCConfiguration with the -LaunchWebUI
parameter would prompt for credentials;
* Added warning message when ApplicationSecret is used while attempting
to export resources for Exchange Online;
Fixes #1629
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function Get-TargetResource

[Parameter()]
[System.String[]]
$GroupTypes,
$GroupTypes = @("Unified"),

[Parameter()]
[System.String]
Expand Down Expand Up @@ -285,6 +285,10 @@ function Set-TargetResource
Write-Verbose -Message "Cannot set mailenabled to false if GroupTypes is set to Unified when creating group."
throw "Cannot set mailenabled to false if GroupTypes is set to Unified when creating a group."
}
if (-not $GroupTypes)
{
$currentParameters.Add("GroupTypes", @("Unified"))
}

if ($Ensure -eq 'Present' -and $currentGroup.Ensure -eq 'Present')
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ function Get-TargetResource
$property = $Script:RecentMPExtract.SearchConfigurationSettings.SearchSchemaConfigurationSettings.ManagedProperties.dictionary.KeyValueOfstringManagedPropertyInfoy6h3NzC8 `
| Where-Object -FilterScript { $_.Value.Name -eq $Name }

[System.Xml.XmlElement]$aliases = $Script:RecentMPExtract.SearchConfigurationSettings.SearchSchemaConfigurationSettings.Aliases.dictionary.KeyValueOfstringAliasInfoy6h3NzC8 `
| Where-Object -FilterScript { $_.Value.ManagedPid -eq $property.Value.Pid }

if ($null -eq $property)
{
Write-Verbose -Message "The specified Managed Property {$($Name)} doesn't already exist."
Expand Down Expand Up @@ -189,20 +192,20 @@ function Get-TargetResource
Name = [string] $property.Value.Name
Type = [string] $property.Value.ManagedType
Description = [string] $property.Value.Description
Searchable = [boolean] $property.Value.Searchable
Searchable = [boolean]::Parse($property.Value.Searchable)
FullTextIndex = $FullTextIndex
FullTextContext = [UInt32] $property.Value.Context
Queryable = [boolean] $property.Value.Queryable
Retrievable = [boolean] $property.Value.Retrievable
AllowMultipleValues = [boolean] $property.Value.HasMultipleValues
Queryable = [boolean]::Parse($property.Value.Queryable)
Retrievable = [boolean]::Parse($property.Value.Retrievable)
AllowMultipleValues = [boolean]::Parse($property.Value.HasMultipleValues)
Refinable = $fixedRefinable
Sortable = $fixedSortable
Safe = [boolean] $property.Value.SafeForAnonymous
Aliases = [boolean] $property.Value.Aliases
TokenNormalization = [boolean] $property.Value.TokenNormalization
CompleteMatching = [boolean] $property.Value.CompleteMatching
LanguageNeutralTokenization = [boolean] $property.Value.LanguageNeutralWordBreaker
FinerQueryTokenization = [boolean] $property.Value.ExpandSegments
Safe = [boolean]::Parse($property.Value.SafeForAnonymous)
Aliases = $aliases.Value.Name
TokenNormalization = [boolean]::Parse($property.Value.TokenNormalization)
CompleteMatching = [boolean]::Parse($property.Value.CompleteMatching)
LanguageNeutralTokenization = [boolean]::Parse($property.Value.LanguageNeutralWordBreaker)
FinerQueryTokenization = [boolean]::Parse($property.Value.ExpandSegments)
MappedCrawledProperties = $mappings
CompanyNameExtraction = $CompanyNameExtraction
Ensure = "Present"
Expand Down Expand Up @@ -391,6 +394,11 @@ function Set-TargetResource
{
$currentPID = $property.Value.Pid
}
else
{
$randomizer = [System.Random]::new()
$currentPID = $randomizer.Next(1000,9999)
}

$prop = $SearchConfigXml.ChildNodes[0].SearchSchemaConfigurationSettings.ManagedProperties.dictionary
$newManagedPropertyElement = $SearchConfigXML.CreateElement("d4p1:KeyValueOfstringManagedPropertyInfoy6h3NzC8", `
Expand Down Expand Up @@ -617,21 +625,24 @@ function Set-TargetResource
$SearchConfigXML.OuterXml | Out-File $tempPath

# Create the Managed Property if it doesn't already exist
Set-PnPSearchConfiguration -Scope Subscription -Path $tempPath
Write-Verbose -Message "Updating core properties for Search Managed Property {$Name}"
Set-PnPSearchConfiguration -Scope 'Subscription' -Path $tempPath

#region Aliases
if ($null -ne $Aliases)
{
$aliasesArray = $Aliases.Split(';')
$aliasProp = $SearchConfigXml.ChildNodes[0].SearchSchemaConfigurationSettings.Aliases.dictionary
$aliasDictNode = $SearchConfigXml.ChildNodes[0].SearchSchemaConfigurationSettings.Aliases.dictionary

if ($null -eq $currentPID)
if ([System.String]::IsNullOrEmpty($currentPID))
{
# Get the managed property back. This is the only way to ensure we have the right PID
$currentConfigXML = [XML] (Get-PnPSearchConfiguration -Scope Subscription)
$property = $currentConfigXML.SearchConfigurationSettings.SearchSchemaConfigurationSettings.ManagedProperties.dictionary.KeyValueOfstringManagedPropertyInfoy6h3NzC8 `
| Where-Object -FilterScript { $_.Value.Name -eq $Name }
[System.Xml.XmlElement]$property = $Script:currentConfigXML.SearchConfigurationSettings.SearchSchemaConfigurationSettings.ManagedProperties.dictionary.KeyValueOfstringManagedPropertyInfoy6h3NzC8 `
| Where-Object -FilterScript { $_.Value.Name -eq $Name }

$currentPID = $property.Value.Pid
Write-Verbose -Message "Found current Pid {$currentPID}"

$node = $SearchConfigXML.CreateElement("d3p1:Pid", `
"http://schemas.datacontract.org/2004/07/Microsoft.Office.Server.Search.Administration")
Expand Down Expand Up @@ -666,21 +677,22 @@ function Set-TargetResource

$node = $SearchConfigXML.CreateElement("d3p1:SchemaId", `
"http://schemas.datacontract.org/2004/07/Microsoft.Office.Server.Search.Administration")
$node.InnerText = "6408"
$node.InnerText = "794"
$valueNode.AppendChild($node) | Out-Null

$mainNode.AppendChild($keyNode) | Out-Null
$mainNode.AppendChild($valueNode) | Out-Null
$aliasProp.AppendChild($mainNode) | Out-Null
$SearchConfigXml.ChildNodes[0].SearchSchemaConfigurationSettings.Aliases.dictionary.AppendChild($mainNode) | Out-Null
}

$tempPath = Join-Path -Path $ENV:TEMP `
-ChildPath ((New-Guid).ToString().Split('-')[0] + ".config")
$SearchConfigXML.OuterXml | Out-File $tempPath
Write-Verbose -Message "Configuring SPO Search Schema with the following XML Document"
Write-Verbose $SearchConfigXML.OuterXML
$SearchConfigXML.OuterXml | Out-File $tempPath

# Create the aliases on the Managed Property
Write-Verbose -Message "Updating Aliases for Search Managed Property {$Name}"
Set-PnPSearchConfiguration -Scope Subscription -Path $tempPath
}
}
Expand Down Expand Up @@ -821,13 +833,18 @@ function Test-TargetResource

Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)"
Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $PSBoundParameters)"

$ValuesToCheck = $PSBoundParameters
$ValuesToCheck.Remove('Credential') | Out-Null
$ValuesToCheck.Remove('ApplicationId') | Out-Null
$ValuesToCheck.Remove('ApplicationSecret') | Out-Null
$ValuesToCheck.Remove('TenantId') | Out-Null
$ValuesToCheck.Remove('CertificateThumbprint') | Out-Null
$ValuesToCheck.Remove('CertificatePath') | Out-Null
$ValuesToCheck.Remove('CertificatePassword') | Out-Null
$TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck @("Ensure", `
"Name",
"Type")
-ValuesToCheck $ValuesToCheck.Keys

Write-Verbose -Message "Test-TargetResource returned $TestResult"

Expand Down
26 changes: 13 additions & 13 deletions Modules/Microsoft365DSC/Dependencies/Manifest.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,55 @@
},
@{
ModuleName = "Microsoft.Graph.Applications"
RequiredVersion = "1.9.0"
RequiredVersion = "1.9.1"
},
@{
ModuleName = "Microsoft.Graph.Authentication"
RequiredVersion = "1.9.0"
RequiredVersion = "1.9.1"
},
@{
ModuleName = "Microsoft.Graph.DeviceManagement"
RequiredVersion = "1.9.0"
RequiredVersion = "1.9.1"
},
@{
ModuleName = "Microsoft.Graph.DeviceManagement.Administration"
RequiredVersion = "1.9.0"
RequiredVersion = "1.9.1"
},
@{
ModuleName = "Microsoft.Graph.DeviceManagement.Enrolment"
RequiredVersion = "1.9.0"
RequiredVersion = "1.9.1"
},
@{
ModuleName = "Microsoft.Graph.Devices.CorporateManagement"
RequiredVersion = "1.9.0"
RequiredVersion = "1.9.1"
},
@{
ModuleName = "Microsoft.Graph.Groups"
RequiredVersion = "1.9.0"
RequiredVersion = "1.9.1"
},
@{
ModuleName = "Microsoft.Graph.Identity.DirectoryManagement"
RequiredVersion = "1.9.0"
RequiredVersion = "1.9.1"
},
@{
ModuleName = "Microsoft.Graph.Identity.Governance"
RequiredVersion = "1.9.0"
RequiredVersion = "1.9.1"
},
@{
ModuleName = "Microsoft.Graph.Identity.SignIns"
RequiredVersion = "1.9.0"
RequiredVersion = "1.9.1"
},
@{
ModuleName = "Microsoft.Graph.Planner"
RequiredVersion = "1.9.0"
RequiredVersion = "1.9.1"
},
@{
ModuleName = "Microsoft.Graph.Teams"
RequiredVersion = "1.9.0"
RequiredVersion = "1.9.1"
},
@{
ModuleName = "Microsoft.Graph.Users"
RequiredVersion = "1.9.0"
RequiredVersion = "1.9.1"
},
@{
ModuleName = "Microsoft.PowerApps.Administration.PowerShell"
Expand Down
2 changes: 1 addition & 1 deletion Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ function Export-M365DSCConfiguration
}

# Default to Credential if no authentication mechanism were provided
if (-not $Credential -and (-not $ApplicationId -or -not $TenantId -or (-not $ApplicationSecret -and -not $CertificateThumbprint)))
if (-not $Credential -and (-not $ApplicationId -or -not $TenantId -or (-not $ApplicationSecret -and -not $CertificateThumbprint)) -and -not $LaunchWebUI)
{
$Credential = Get-Credential
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
<d3p1:CompleteMatching>false</d3p1:CompleteMatching>
<d3p1:Context>0</d3p1:Context>
<d3p1:DeleteDisallowed>false</d3p1:DeleteDisallowed>
<d3p1:Description/>
<d3p1:Description>This is a test</d3p1:Description>
<d3p1:EnabledForScoping>false</d3p1:EnabledForScoping>
<d3p1:EntityExtractorBitMap>4161</d3p1:EntityExtractorBitMap>
<d3p1:ExpandSegments>false</d3p1:ExpandSegments>
<d3p1:FullTextIndex/>
<d3p1:FullTextIndex>0</d3p1:FullTextIndex>
<d3p1:HasMultipleValues>false</d3p1:HasMultipleValues>
<d3p1:IndexOptions>0</d3p1:IndexOptions>
<d3p1:IsImplicit>false</d3p1:IsImplicit>
Expand Down Expand Up @@ -210,7 +210,6 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
Credential = $Credential
}
Mock -CommandName Get-PnPSearchConfiguration -MockWith {

return $existingValueXML
}

Expand Down