microsoft / Microsoft365DSC

Manages, configures, extracts and monitors Microsoft 365 tenant configurations
https://aka.ms/M365DSC
MIT License
1.61k stars 500 forks source link

EXOSharedMailbox: Invoke-DscResource -Test: Resource not found #4434

Open fasteiner opened 8 months ago

fasteiner commented 8 months ago

Description of the issue

Until version 1.24.117.1 I did not get this error, since version 1.24.221.1 I get the following error:

image

code:

` $sharedMailboxConfig = @{ Name = 'EXOSharedMailbox' Property = @{ DisplayName = $displayName Alias = $json.mail.trim() PrimarySMTPAddress = "$($primarySMTPAddress.trim())" EmailAddresses = @("$($json.mail)@tttech365.mail.onmicrosoft.com", "$($json.mail)@tttech365.onmicrosoft.com") Ensure = ($json.requestType -like "delete")? ( "Absent" ) : ( "Present" ) ApplicationId = $env:APPREGID TenantId = $env:AzureTenant CertificatePath = $env:CERT_CONTENT CertificatePassword = (New-Object System.Management.Automation.PSCredential -ArgumentList "CertificatePassword", $password) } ModuleName = 'Microsoft365DSC'

Verbose = $true

}

Invoke-DscResource @sharedMailboxConfig -Method Set | Out-Null

`

I rolled back to Version 1.24.117.1 for now.

Curiously the problem only exists when creating new resources, as I applied a configuration to a existing mailbox, it worked

Microsoft 365 DSC Version

1.24.221.1 + 1.24.228.1

Which workloads are affected

Exchange Online

The DSC configuration

$sharedMailboxConfig = @{
        Name       = 'EXOSharedMailbox'
        Property   = @{
            DisplayName         = $displayName
            Alias               = $json.mail.trim()
            PrimarySMTPAddress  = "$($primarySMTPAddress.trim())"
            EmailAddresses      = @("$($json.mail)@tttech365.mail.onmicrosoft.com", "$($json.mail)@tttech365.onmicrosoft.com")
            Ensure              = ($json.requestType -like "*delete*")? ( "Absent" ) : ( "Present" )
            ApplicationId       = $env:APPREGID
            TenantId            = $env:AzureTenant
            CertificatePath     = $env:CERT_CONTENT
            CertificatePassword = (New-Object System.Management.Automation.PSCredential -ArgumentList "CertificatePassword", $password)
        }
        ModuleName = 'Microsoft365DSC'
        #Verbose    = $true
    }

Verbose logs showing the problem

No response

Environment Information + PowerShell Version

OsName               : Microsoft Windows Server 2019 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 1809
WindowsBuildLabEx    : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
andikrueger commented 8 months ago

Oils you share the outcome of get-DscResource for this resource?

fasteiner commented 8 months ago

Oils you share the outcome of get-DscResource for this resource?

What do you mean by "Oils you share"? @andikrueger

andikrueger commented 8 months ago

Could… obvious typo on my end.

fasteiner commented 8 months ago

As I rolled back the server (need a working version for prod), I can only provide the output from my own machine:

Get-DscResource EXOSharedMailbox

ImplementationDetail : ScriptBased
ResourceType         : MSFT_EXOSharedMailbox
Name                 : EXOSharedMailbox
FriendlyName         : EXOSharedMailbox
Module               : Microsoft365DSC
ModuleName           : Microsoft365DSC
Version              : 1.24.228.1
Path                 : C:\Users\fasteiner\OneDrive - TTTECH COMPUTERTECHNIK
                       AG\Documents\PowerShell\Modules\Microsoft365DSC\1.24.228.1\DscResources\MSFT_EXOSharedMailbox\MSFT_EXOSharedMailbox.psm1
ParentPath           : C:\Users\fasteiner\OneDrive - TTTECH COMPUTERTECHNIK AG\Documents\PowerShell\Modules\Microsoft365DSC\1.24.228.1\DscResources\MSFT_EXOSharedMailbox
ImplementedAs        : PowerShell
CompanyName          : Microsoft Corporation
Properties           : {DisplayName, Alias, ApplicationId, CertificatePassword…}
NikCharlebois commented 8 months ago

We are not able to replicate on our end. Curious if you get the same results with PowerShell 5?

fasteiner commented 7 months ago

I just ran it interactively in Powershell 7 - works fine, when I launch it from Jenkins it does not find the resource - very curious.

fasteiner commented 7 months ago

Ahhh I found the issue:

works fine: Invoke-DscResource @sharedMailboxConfig -Method Set

throws the mentioned error: $state = Invoke-DscResource @sharedMailboxConfig -Method Test

can you replicate that? @NikCharlebois

fasteiner commented 7 months ago

Seems to happen with other resources as well: image

fasteiner commented 7 months ago

seems this occurs when Invoke-DscResource is run multiple times

fasteiner commented 7 months ago

Temporary Workaround: run every single command in a child job, to have a new context everytime

fasteiner commented 5 months ago

@NikCharlebois any updates?