Skip to content

Commit

Permalink
Merge pull request #5547 from FabienTschanz/fix/workloads-for-resources
Browse files Browse the repository at this point in the history
Update input variety for workloads by resource names
  • Loading branch information
NikCharlebois authored Dec 13, 2024
2 parents fde3c01 + aa7fdf3 commit a2d411e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# UNRELEASED

* M365DSCUtil
* Update `Get-M365DSCWorkloadsListFromResourceNames` function for more input types.
FIXES [#5525](https://github.com/microsoft/Microsoft365DSC/issues/5525)

# 1.24.1211.1

* AADApplication
Expand Down
41 changes: 27 additions & 14 deletions Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -4207,13 +4207,20 @@ function Test-M365DSCObjectHasProperty

<#
.Description
This function returns the used workloads for the specified DSC resources
This function returns the used workloads for the specified DSC resources
.Parameter ResourceNames
Specifies the resources for which the workloads should be determined.
Specifies the resources for which the workloads should be determined.
Either a single string, an array of strings or an object with 'Name' and 'AuthenticationMethod' can be provided.
.Example
Get-M365DSCWorkloadsListFromResourceNames -ResourceNames AADUSer
Get-M365DSCWorkloadsListFromResourceNames -ResourceNames AADUser
.EXAMPLE
Get-M365DSCWorkloadsListFromResourceNames -ResourceNames @('AADUser', 'AADGroup')
.EXAMPLE
Get-M365DSCWorkloadsListFromResourceNames -ResourceNames @{Name = 'AADUser'; AuthenticationMethod = 'Credentials'}
.Functionality
Public
Expand All @@ -4232,15 +4239,21 @@ function Get-M365DSCWorkloadsListFromResourceNames
[Array] $workloads = @()
foreach ($resource in $ResourceNames)
{
switch ($resource.Name.Substring(0, 2).ToUpper())
$resourceName = $resource.Name
$authMethod = $resource.AuthenticationMethod
if ([System.String]::IsNullOrEmpty($resourceName))
{
$resourceName = $resource
}
switch ($resourceName.Substring(0, 2).ToUpper())
{
'AA'
{
if (-not $workloads.Name -or -not $workloads.Name.Contains('MicrosoftGraph'))
{
$workloads += @{
Name = 'MicrosoftGraph'
AuthenticationMethod = $resource.AuthenticationMethod
AuthenticationMethod = $authMethod
}
}
}
Expand All @@ -4250,7 +4263,7 @@ function Get-M365DSCWorkloadsListFromResourceNames
{
$workloads += @{
Name = 'ExchangeOnline'
AuthenticationMethod = $resource.AuthenticationMethod
AuthenticationMethod = $authMethod
}
}
}
Expand All @@ -4260,7 +4273,7 @@ function Get-M365DSCWorkloadsListFromResourceNames
{
$workloads += @{
Name = 'MicrosoftGraph'
AuthenticationMethod = $resource.AuthenticationMethod
AuthenticationMethod = $authMethod
}
}
}
Expand All @@ -4270,14 +4283,14 @@ function Get-M365DSCWorkloadsListFromResourceNames
{
$workloads += @{
Name = 'MicrosoftGraph'
AuthenticationMethod = $resource.AuthenticationMethod
AuthenticationMethod = $authMethod
}
}
elseif (-not $workloads.Name -or -not $workloads.Name.Contains('ExchangeOnline'))
{
$workloads += @{
Name = 'ExchangeOnline'
AuthenticationMethod = $resource.AuthenticationMethod
AuthenticationMethod = $authMethod
}
}
}
Expand All @@ -4287,7 +4300,7 @@ function Get-M365DSCWorkloadsListFromResourceNames
{
$workloads += @{
Name = 'PnP'
AuthenticationMethod = $resource.AuthenticationMethod
AuthenticationMethod = $authMethod
}
}
}
Expand All @@ -4297,7 +4310,7 @@ function Get-M365DSCWorkloadsListFromResourceNames
{
$workloads += @{
Name = 'MicrosoftGraph'
AuthenticationMethod = $resource.AuthenticationMethod
AuthenticationMethod = $authMethod
}
}
}
Expand All @@ -4307,7 +4320,7 @@ function Get-M365DSCWorkloadsListFromResourceNames
{
$workloads += @{
Name = 'PnP'
AuthenticationMethod = $resource.AuthenticationMethod
AuthenticationMethod = $authMethod
}
}
}
Expand All @@ -4317,7 +4330,7 @@ function Get-M365DSCWorkloadsListFromResourceNames
{
$workloads += @{
Name = 'SecurityComplianceCenter'
AuthenticationMethod = $resource.AuthenticationMethod
AuthenticationMethod = $authMethod
}
}
}
Expand All @@ -4327,7 +4340,7 @@ function Get-M365DSCWorkloadsListFromResourceNames
{
$workloads += @{
Name = 'MicrosoftTeams'
AuthenticationMethod = $resource.AuthenticationMethod
AuthenticationMethod = $authMethod
}
}
}
Expand Down

0 comments on commit a2d411e

Please sign in to comment.