Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into Release-1.22.720.1
Browse files Browse the repository at this point in the history
  • Loading branch information
NikCharlebois committed Jul 20, 2022
2 parents 911a530 + 5e44e5b commit 981693c
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 26 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

# UNRELEASED

* EXOCASMailboxSettings
* Fixed issue if there are mailboxes with the same name
FIXES [#2117](https://github.com/microsoft/Microsoft365DSC/issues/2117)
* AADGroup
* Added support for Group Licensing by adding the AssignedLicenses property.
* Added support for members and owners.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function Get-TargetResource
Write-Verbose -Message "Getting configuration of AzureAD Authorization Policy"
$ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' `
-InboundParameters $PSBoundParameters `
-ProfileName 'beta'
-ProfileName 'v1.0'

#Ensure the proper dependencies are installed in the current environment.
Confirm-M365DSCDependencies
Expand Down Expand Up @@ -134,7 +134,10 @@ function Get-TargetResource
DefaultUserRoleAllowedToCreateApps = $Policy.DefaultUserRolePermissions.AllowedToCreateApps
DefaultUserRoleAllowedToCreateSecurityGroups = $Policy.DefaultUserRolePermissions.AllowedToCreateSecurityGroups
DefaultUserRoleAllowedToReadOtherUsers = $Policy.DefaultUserRolePermissions.AllowedToReadOtherUsers
PermissionGrantPolicyIdsAssignedToDefaultUserRole = $Policy.PermissionGrantPolicyIdsAssignedToDefaultUserRole
#v1.0 profile
PermissionGrantPolicyIdsAssignedToDefaultUserRole = $Policy.DefaultUserRolePermissions.PermissionGrantPoliciesAssigned
#beta-profile
#PermissionGrantPolicyIdsAssignedToDefaultUserRole = $Policy.PermissionGrantPolicyIdsAssignedToDefaultUserRole
GuestUserRole = Get-GuestUserRoleNameFromId -GuestUserRoleId $Policy.GuestUserRoleId
#Standard part
Ensure = "Present"
Expand Down Expand Up @@ -278,8 +281,12 @@ function Set-TargetResource
{
if ($param -like 'Permission*')
{
$UpdateParameters.Add($param, $currentParameters.$param)
Write-Verbose -Message "Added '$param' to UpdateParameters"
#beta profile
#$UpdateParameters.Add($param, $currentParameters.$param)
#Write-Verbose -Message "Added '$param' to UpdateParameters"
#v1.0 profile
$defaultUserRolePermissions.Add('PermissionGrantPoliciesAssigned', $currentParameters.$param)
Write-Verbose -Message "Added 'PermissionGrantPoliciesAssigned' ($param) to defaultUserRolePermissions"
}
else
{
Expand Down Expand Up @@ -313,11 +320,7 @@ function Set-TargetResource
if ($defaultUserRolePermissions.Keys.Count -gt 0)
{
Write-Verbose -Message "Add 'DefaultUserRolePermissions' to UpdateParameters"
$UpdateParameters.Add('DefaultUserRolePermissions', @{}) # New-Object
foreach ($key in $defaultUserRolePermissions.keys) {
$UpdateParameters.defaultUserRolePermissions.Add($key, $defaultUserRolePermissions.$key) | Out-Null
Write-Verbose -Message "Add '$key' to UpdateParameters.defaultUserRolePermissions"
}
$UpdateParameters.Add('DefaultUserRolePermissions', $defaultUserRolePermissions.Clone())
}

try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -752,12 +752,12 @@ function Export-TargetResource
foreach ($mailbox in $mailboxes)
{
Write-Host " |---[$i/$($mailboxes.Length)] $($mailbox.Name)" -NoNewline
$mailboxName = $mailbox.Name
$mailboxName = $mailbox.UserPrincipalName
if (![System.String]::IsNullOrEmpty($mailboxName))
{
$Params = @{
Credential = $Credential
Identity = $mailbox.Name
Identity = $mailboxName
ApplicationId = $ApplicationId
TenantId = $TenantId
CertificateThumbprint = $CertificateThumbprint
Expand Down
71 changes: 64 additions & 7 deletions Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2341,6 +2341,7 @@ function Test-M365DSCDependenciesForNewVersions
$dependencies = $manifest.Dependencies
$i = 1
Import-Module PowerShellGet -Force

foreach ($dependency in $dependencies)
{
Write-Progress -Activity "Scanning Dependencies" -PercentComplete ($i / $dependencies.Count * 100)
Expand Down Expand Up @@ -2477,14 +2478,18 @@ function Uninstall-M365DSCOutdatedDependencies

$InformationPreference = 'Continue'

$microsoft365DscModules = Get-Module Microsoft365DSC -ListAvailable
[array]$microsoft365DscModules = Get-Module Microsoft365DSC -ListAvailable
$outdatedMicrosoft365DscModules = $microsoft365DscModules | Sort-Object Version | Select-Object -SkipLast 1

foreach ($module in $outdatedMicrosoft365DscModules)
{
try
{
Uninstall-Module -Name "$($module.Name)" -RequiredVersion "$($module.Version)"
Write-Information -Message "Uninstalling $($module.Name) Version {$($module.Version)}"
if (Test-Path -Path $($module.Path))
{
Remove-Item $($module.Path) -Force -Recurse
}
}
catch
{
Expand All @@ -2493,7 +2498,7 @@ function Uninstall-M365DSCOutdatedDependencies
}

$currentPath = Join-Path -Path $PSScriptRoot -ChildPath '..\' -Resolve
$manifest = Import-PowerShellDataFile "$currentPath/Dependencies/Manifest.psd1"
$manifest = Import-PowerShellDataFile "$currentPath\Dependencies\Manifest.psd1"

$allDependenciesExceptAuth = $manifest.Dependencies | Where-Object { $_.ModuleName -ne "Microsoft.Graph.Authentication" }

Expand All @@ -2508,8 +2513,11 @@ function Uninstall-M365DSCOutdatedDependencies
{
try
{
Write-Information -Message "Uninstalling $($foundModule.Name) version {$($foundModule.Version)}"
Uninstall-Module -Name "$($foundModule.Name)" -RequiredVersion "$($foundModule.Version)"
Write-Information -Message "Uninstalling $($foundModule.Name) Version {$($foundModule.Version)}"
if (Test-Path -Path $($foundModule.Path))
{
Remove-Item $($foundModule.Path) -Force -Recurse
}
}
catch
{
Expand All @@ -2534,7 +2542,10 @@ function Uninstall-M365DSCOutdatedDependencies
try
{
Write-Information -Message "Uninstalling $($foundModule.Name) version {$($foundModule.Version)}"
Uninstall-Module -Name "$($foundModule.Name)" -RequiredVersion "$($foundModule.Version)" -Force
if (Test-Path -Path $($foundModule.Path))
{
Remove-Item $($foundModule.Path) -Force -Recurse
}
}
catch
{
Expand Down Expand Up @@ -3482,6 +3493,51 @@ function New-M365DSCMissingResourcesExample
}
}




<#
.Description
This function validates there are no updates to the module or it's dependencies and no multiple versions are present on the local system.
.Parameter Force
Specifies that all dependencies should be forcefully imported again.
.Example
Test-M365DSCModuleValidity
.Example
Test-M365DSCModuleValidity -Force
.Functionality
Public
#>
function Test-M365DSCModuleValidity
{
[CmdletBinding()]
param(
)
$InformationPreference = 'Continue'

# validate only one installation of the module is present (and it's the latest version available from the psgallery)
$latestVersion = (Find-Module -Name 'Microsoft365DSC').Version
$localVersion = (Get-Module -Name 'Microsoft365DSC').Version

if ($latestVersion -gt $localVersion)
{
Write-Host "There is a newer version of the 'Microsoft365DSC' module available on the gallery."
Write-Host "To update the module and it's dependencies, run the following commands:"
Write-Host "Update-Module -Name 'Microsoft365DSC' -Force`nUpdate-M365DSCDependencies -Force`nUninstall-M365DSCOutdatedDependencies" -ForegroundColor Blue
# if(!( $UpdateConsent = Read-Host -Prompt "Do you wish to update the M365DSC module and it's dependencies? (Y/N) [Default: 'Y']")) { $UpdateConsent = 'Y' }
# if(!( $UpdateConsent -eq 'Y' -or $UpdateConsent -eq 'y' )) { return }
# Write-Host "Updating the M365DSC module..." -ForegroundColor Yellow
# Update-Module -Name 'Microsoft365DSC' -Force
# Write-Host "Updating dependencies..." -ForegroundColor Yellow
#Update-M365DSCDependencies -Force
# Write-Host "uninstalling outdated installations..." -ForegroundColor Yellow
# Uninstall-M365DSCOutdatedDependencies
}
}
Export-ModuleMember -Function @(
'Assert-M365DSCBlueprint',
'Confirm-ImportedCmdletIsAvailable',
Expand Down Expand Up @@ -3519,5 +3575,6 @@ Export-ModuleMember -Function @(
'Test-M365DSCParameterState',
'Uninstall-M365DSCOutdatedDependencies',
'Update-M365DSCDependencies',
'Update-M365DSCExportAuthenticationResults'
'Update-M365DSCExportAuthenticationResults',
'Test-M365DSCModuleValidity'
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ Import-Module -Name (Join-Path -Path $M365DSCTestFolder `
-ChildPath "\UnitTestHelper.psm1" `
-Resolve)

# appears required in order to get Pester to mock the correct version of Graph-cmdlets. If missing, Pester'll base mocks on the v1.0 cmdlets.
Select-MgProfile -Name beta

$Global:DscHelper = New-M365DscUnitTestHelper -StubModule $CmdletModule `
-DscResource "AADAuthorizationPolicy" -GenericStubModule $GenericStubPath
Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
Expand Down Expand Up @@ -67,7 +64,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
DefaultuserRoleAllowedToCreateApps = $true
DefaultUserRoleAllowedToCreateSecurityGroups = $true
DefaultUserRoleAllowedToReadOtherUsers = $true
PermissionGrantPolicyIdsAssignedToDefaultUserRole = @()
PermissionGrantPolicyIdsAssignedToDefaultUserRole = [string[]]@()
GuestUserRole = 'Guest'
Ensure = "Present"
Credential = $Credential
Expand All @@ -90,8 +87,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
allowedToCreateApps = $true
allowedToCreateSecurityGroups = $true
allowedToReadOtherUsers = $true
PermissionGrantPoliciesAssigned = [string[]]@()
}
PermissionGrantPolicyIdsAssignedToDefaultUserRole = @()
GuestUserRoleId = '10dae51f-b6af-4016-8d66-8c2a99b929b3' # Guest
}
return $AADAuthPol
Expand Down Expand Up @@ -122,7 +119,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
DefaultuserRoleAllowedToCreateApps = $true
DefaultUserRoleAllowedToCreateSecurityGroups = $true
DefaultUserRoleAllowedToReadOtherUsers = $true
PermissionGrantPolicyIdsAssignedToDefaultUserRole = @()
PermissionGrantPolicyIdsAssignedToDefaultUserRole = [string[]]@()
GuestUserRole = 'RestrictedGuest'
Ensure = "Present"
Credential = $Credential
Expand All @@ -146,8 +143,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
allowedToCreateApps = $true
allowedToCreateSecurityGroups = $true
allowedToReadOtherUsers = $true
PermissionGrantPoliciesAssigned = [string[]]@()
}
PermissionGrantPolicyIdsAssignedToDefaultUserRole = @()
GuestUserRoleId = '10dae51f-b6af-4016-8d66-8c2a99b929b3' # Guest
}
return $AADAuthPol
Expand Down Expand Up @@ -197,8 +194,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
allowedToCreateApps = $true
allowedToCreateSecurityGroups = $true
allowedToReadOtherUsers = $true
PermissionGrantPoliciesAssigned = [string[]]@()
}
PermissionGrantPolicyIdsAssignedToDefaultUserRole = @()
GuestUserRoleId = '10dae51f-b6af-4016-8d66-8c2a99b929b3' # Guest
}
return $AADAuthPol
Expand Down

0 comments on commit 981693c

Please sign in to comment.