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

Get-M365DSCWorkloadsListFromResourceNames not working #5525

Closed
PsySuck opened this issue Dec 8, 2024 · 1 comment · Fixed by #5547 or #5584
Closed

Get-M365DSCWorkloadsListFromResourceNames not working #5525

PsySuck opened this issue Dec 8, 2024 · 1 comment · Fixed by #5547 or #5584

Comments

@PsySuck
Copy link

PsySuck commented Dec 8, 2024

Description of the issue

I am trying to run Get-M365DSCWorkloadsListFromResourceNames from [doc]https://microsoft365dsc.com/user-guide/cmdlets/Get-M365DSCWorkloadsListFromResourceNames/(url)
Get-M365DSCWorkloadsListFromResourceNames -ResourceNames AADUSer
I got for any Resource

Get-M365DSCWorkloadsListFromResourceNames -ResourceNames AADUSer
You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.1127.1\Modules\M365DSCUtil.psm1:4224 char:14
+     foreach ($resource in $ResourceNames)
+              ~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Microsoft 365 DSC Version

1.24.1127.1

Which workloads are affected

other

The DSC configuration

Verbose logs showing the problem

Environment Information + PowerShell Version

OsName               : Microsoft Windows Server 2022 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 20348.2849.amd64fre.fe_release_svc_prod1.241101-1732
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

Name                           Value
----                           -----
PSVersion                      5.1.20348.2849
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.20348.2849
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
@FabienTschanz
Copy link
Contributor

@NikCharlebois Question here. The function Get-M365DSCWorkloadsListFromResourceNames is supposed to return the workloads from given input resources. The example is as the @PsySuck describes: Get-M365DSCWorkloadsListFromResourceNames -ResourceNames AADUser. But now the caveat: Inside of the function, it's expected that the input resources contain a Name and a AuthenticationMethod property? Why is that the case? The function description doesn't contain any more information about it.

switch ($resource.Name.Substring(0, 2).ToUpper())
{
    'AA'
    {
        if (-not $workloads.Name -or -not $workloads.Name.Contains('MicrosoftGraph'))
        {
            $workloads += @{
                Name                 = 'MicrosoftGraph'
                AuthenticationMethod = $resource.AuthenticationMethod
            }
        }
    }
...
}

The call to $resource.Name.Substring(...) leads to the exception of the issue. In my opinion, this is an error and should be corrected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants