Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NikCharlebois committed Aug 29, 2022
1 parent 7357594 commit 4835927
Show file tree
Hide file tree
Showing 25 changed files with 7,211 additions and 3,235 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ function Test-TargetResource
$TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys -Verbose
-ValuesToCheck $ValuesToCheck.Keys
}

Write-Verbose -Message "Test-TargetResource returned $TestResult"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ function Get-TargetResource
$context=Get-MgContext
if($null -eq $context)
{
New-M365DSCConnection -Workload 'MicrosoftGraph' -InboundParameters $PSBoundParameters -ErrorAction Stop
$ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' -InboundParameters $PSBoundParameters -ErrorAction Stop -ProfileName 'beta'
}

Write-Verbose -Message "Select-MgProfile"
Select-MgProfile -Name 'beta'
#Ensure the proper dependencies are installed in the current environment.
Confirm-M365DSCDependencies

Expand Down Expand Up @@ -185,7 +183,6 @@ function Set-TargetResource
-InboundParameters $PSBoundParameters `
-ProfileName 'beta'

Select-MgProfile -Name 'beta'
#Ensure the proper dependencies are installed in the current environment.
Confirm-M365DSCDependencies

Expand Down Expand Up @@ -372,8 +369,8 @@ function Export-TargetResource
$CertificateThumbprint
)

$ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' -InboundParameters $PSBoundParameters -SkipModuleReload:$true
Select-MgProfile -Name 'Beta'
$ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' -InboundParameters $PSBoundParameters -SkipModuleReload:$true -ProfileName 'beta'

#Ensure the proper dependencies are installed in the current environment.
Confirm-M365DSCDependencies

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ function Test-TargetResource
$TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys -Verbose
-ValuesToCheck $ValuesToCheck.Keys
}

Write-Verbose -Message "Test-TargetResource returned $TestResult"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,8 @@ function Test-TargetResource

$CurrentValues = Get-TargetResource @PSBoundParameters

#Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)"
#Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $PSBoundParameters)"
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
Expand Down Expand Up @@ -832,8 +832,7 @@ function Test-TargetResource
$TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys `
-Verbose
-ValuesToCheck $ValuesToCheck.Keys

}
Write-Verbose -Message "Test-TargetResource returned $TestResult"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function Get-TargetResource
DeviceThreatProtectionRequiredSecurityLevel = $devicePolicy.AdditionalProperties.deviceThreatProtectionRequiredSecurityLevel
ManagedEmailProfileRequired = $devicePolicy.AdditionalProperties.managedEmailProfileRequired
Ensure = 'Present'
Credential = $Credential
Credential = $Credential
ApplicationId = $ApplicationId
TenantId = $TenantId
ApplicationSecret = $ApplicationSecret
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1171,8 +1171,8 @@ function Test-TargetResource
$ValuesToCheck.Remove('TenantId') | Out-Null
$ValuesToCheck.Remove('ApplicationSecret') | Out-Null

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

#Convert any DateTime to String
foreach ($key in $ValuesToCheck.Keys)
Expand All @@ -1189,7 +1189,7 @@ function Test-TargetResource
$testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys -verbose
-ValuesToCheck $ValuesToCheck.Keys
}

Write-Verbose -Message "Test-TargetResource returned $testResult"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ function Test-TargetResource
$testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys -verbose
-ValuesToCheck $ValuesToCheck.Keys
}

Write-Verbose -Message "Test-TargetResource returned $testResult"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ function Test-TargetResource
$testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys -verbose
-ValuesToCheck $ValuesToCheck.Keys
}

Write-Verbose -Message "Test-TargetResource returned $testResult"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ function Test-TargetResource
$TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys -Verbose
-ValuesToCheck $ValuesToCheck.Keys
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ function Test-TargetResource
$testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys -verbose
-ValuesToCheck $ValuesToCheck.Keys
}

Write-Verbose -Message "Test-TargetResource returned $testResult"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ function Test-TargetResource
$testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys -verbose
-ValuesToCheck $ValuesToCheck.Keys
}

Write-Verbose -Message "Test-TargetResource returned $testResult"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ function Test-TargetResource
$testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys -verbose
-ValuesToCheck $ValuesToCheck.Keys
}

Write-Verbose -Message "Test-TargetResource returned $testResult"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ function Test-TargetResource
$testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys -verbose
-ValuesToCheck $ValuesToCheck.Keys
}

Write-Verbose -Message "Test-TargetResource returned $testResult"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ function Test-TargetResource
$testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys -verbose
-ValuesToCheck $ValuesToCheck.Keys
}

Write-Verbose -Message "Test-TargetResource returned $testResult"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ function Test-TargetResource
$testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys -verbose
-ValuesToCheck $ValuesToCheck.Keys
}

Write-Verbose -Message "Test-TargetResource returned $testResult"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ function Test-TargetResource
$testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys -verbose
-ValuesToCheck $ValuesToCheck.Keys
}

Write-Verbose -Message "Test-TargetResource returned $testResult"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ function Test-TargetResource
$testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys -verbose
-ValuesToCheck $ValuesToCheck.Keys
}

Write-Verbose -Message "Test-TargetResource returned $testResult"
Expand Down
11 changes: 7 additions & 4 deletions Modules/Microsoft365DSC/Modules/M365DSCStubsUtility.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,16 @@ function New-M365DSCStubFiles
$cmdlets = Get-Command -CommandType 'Cmdlet' | Where-Object -FilterScript { $_.Source -eq $CurrentModuleName }
if ($null -eq $cmdlets -or $Module.ModuleName -eq 'MicrosoftTeams')
{
$cmdlets += Get-Command -CommandType 'Function' | Where-Object -FilterScript { $_.Source -eq $CurrentModuleName }
$cmdlets += Get-Command -CommandType 'Function' -Module $CurrentModuleName
}

if ($CurrentModuleName -eq 'MicrosoftGraph')
if ($Module.Name -eq 'MicrosoftGraph')
{
Write-Host "Loading Beta Graph APIs"
$MaximumFunctionCount = 32000
Select-MgProfile -Name beta | Out-Null
$betaCmdlets = Get-Command -CommandType 'Cmdlet' | Where-Object -FilterScript { $_.Source -eq $CurrentModuleName }
$betaCmdlets = Get-Command -CommandType 'Cmdlet' -Module $CurrentModuleName
$betaCmdlets += Get-Command -CommandType 'Function' -Module $CurrentModuleName
foreach ($cmdlet in $betaCmdlets)
{
if ($cmdlets.Name -notcontains $cmdlet.Name)
Expand Down Expand Up @@ -206,8 +208,8 @@ function New-M365DSCStubFiles
}
}
$StubContent += "`r`n )`r`n}`n"
$i ++
}
$i ++
}
Write-Progress -Activity "Generating Stubs" -Completed

Expand All @@ -224,6 +226,7 @@ function New-M365DSCStubFiles
$Content += $StubContent
$Content += "#endregion`r`n"
$i++
Remove-Module $CurrentModuleName
}
$Content | Out-File $DestinationFilePath -Encoding utf8
}
Expand Down
2 changes: 1 addition & 1 deletion ResourceGenerator/Module.Template.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ function Test-TargetResource
$testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys -verbose
-ValuesToCheck $ValuesToCheck.Keys
}

Write-Verbose -Message "Test-TargetResource returned $testResult"
Expand Down
Loading

0 comments on commit 4835927

Please sign in to comment.