Skip to content

Commit

Permalink
Merge pull request #4787 from NikCharlebois/Fixes-#4782
Browse files Browse the repository at this point in the history
Fixes #4782
  • Loading branch information
NikCharlebois committed Jun 25, 2024
2 parents d90bb67 + 49b141e commit 8fae485
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ function Set-TargetResource
$currentParameters.Remove('Owners') | Out-Null
$currentParameters.Remove('Members') | Out-Null
$currentParameters.Remove('MemberOf') | Out-Null
#$currentParameters.Remove('AssignedToRole') | Out-Null
$currentParameters.Remove('AssignedToRole') | Out-Null

if ($Ensure -eq 'Present' -and `
($null -ne $GroupTypes -and $GroupTypes.Contains('Unified')) -and `
Expand Down Expand Up @@ -533,7 +533,7 @@ function Set-TargetResource
if ($Ensure -eq 'Present' -and $currentGroup.Ensure -eq 'Absent')
{
Write-Verbose -Message "Checking to see if an existing deleted group exists with DisplayName {$DisplayName}"
$restorinExisting = $false
$restoringExisting = $false
[Array]$groups = Get-MgBetaDirectoryDeletedItemAsGroup -Filter "DisplayName eq '$DisplayName'"
if ($groups.Length -gt 1)
{
Expand Down Expand Up @@ -794,7 +794,7 @@ function Set-TargetResource
}
}

if ($currentGroup.IsAssignableToRole -eq $true -and $currentParameters.ContainsKey('AssignedToRole'))
if ($currentGroup.IsAssignableToRole -eq $true -and $PSBoundParameters.ContainsKey('AssignedToRole'))
{
#AssignedToRole
$currentAssignedToRoleValue = @()
Expand Down
2 changes: 1 addition & 1 deletion Modules/Microsoft365DSC/Modules/M365DSCReverse.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ function Start-M365DSCConfigurationExtract

try
{
$Global:M365DSCExportContentSize = ((Get-Item -Path $outputDSCFile).Length/1KB).ToString().Split('.')[0] + " kb"
$Global:M365DSCExportContentSize = $DSCContent.Length
}
catch
{
Expand Down
14 changes: 12 additions & 2 deletions Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,11 @@ function Get-M365DSCTenantNameFromParameterSet
[System.Collections.HashTable]
$ParameterSet
)
if ($ParameterSet.TenantId)
if ($ParameterSet.ContainsKey('TenantId'))
{
return $ParameterSet.TenantId
}
elseif ($ParameterSet.Credential)
elseif ($ParameterSet.ContainsKey('Credential'))
{
try
{
Expand Down Expand Up @@ -584,6 +584,9 @@ function Test-M365DSCParameterState
$dataEvaluation.Add('Resource', "$Source")
$dataEvaluation.Add('Method', 'Test-TargetResource')
$dataEvaluation.Add('Tenant', $TenantName)

$ConnectionMode = Get-M365DSCAuthenticationMode $DesiredValues
$dataEvaluation.Add('ConnectionMode', $ConnectionMode)
$ValuesToCheckData = $ValuesToCheck | Where-Object -FilterScript {$_ -ne 'Verbose'}
$dataEvaluation.Add('Parameters', $ValuesToCheckData -join "`r`n")
$dataEvaluation.Add('ParametersCount', $ValuesToCheckData.Length)
Expand Down Expand Up @@ -3439,6 +3442,13 @@ function Get-M365DSCExportContentForResource
$Resource = $Script:AllM365DscResources.Where({ $_.Name -eq $ResourceName })
$Keys = $Resource.Properties.Where({ $_.IsMandatory }) | `
Select-Object -ExpandProperty Name
if ($null -eq $keys)
{
Import-Module $Resource.Path -Force
$moduleInfo = Get-Command -Module $ModuleFullName -ErrorAction SilentlyContinue
$cmdInfo = $moduleInfo | Where-Object -FilterScript {$_.Name -eq 'Get-TargetResource'}
$Keys = $cmdInfo.Parameters.Keys
}
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
GroupTypes = @()
MailNickname = 'M365DSC'
IsAssignableToRole = $true
Ensure = 'Present'
}
}
Mock -CommandName Get-MgGroupMemberOf -MockWith {
Expand Down

0 comments on commit 8fae485

Please sign in to comment.