EXOSharedMailbox: Loading of module / connection to ExchangeOnline not proper
fasteiner opened this issue · 0 comments
Description of the issue
Code:
(see configuration below)
Invoke-DscResource @sharedMailboxConfig -Method Set
Gives me the error:
Set-TargetResource: The term 'New-MailBox' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a
path was included,
verify that the path is correct and try again.
When issuing this command before the Set it produces the same error:
Connect-ExchangeOnline -CertificateFilePath $env:CERT_CONTENT -CertificatePassword $password -AppID $env:APPREGID -Organization $env:AzureTenant -ShowBanner:$false
However, if I run the connect after the set, then The New-Mailbox command is known. It is impossible to test the set afterwards because of my already open issue: #4434
I tried downgrading a few versions, but this does not solve the issue. The problems presist since we updated to the latest version. Unfourtunatley I did not write down, which version we were on, but it was definitely a few months old.
Microsoft 365 DSC Version
1.24.529.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
VERBOSE: Returning precomputed version info: 3.4.0
VERBOSE: ModuleVersion: 3.4.0
......
......
VERBOSE: Exporting function 'Get-TargetResource'.
VERBOSE: Exporting function 'Set-TargetResource'.
VERBOSE: Exporting function 'Test-TargetResource'.
VERBOSE: Exporting function 'Export-TargetResource'.
VERBOSE: Importing function 'Export-TargetResource'.
VERBOSE: Importing function 'Get-TargetResource'.
VERBOSE: Importing function 'Set-TargetResource'.
VERBOSE: Importing function 'Test-TargetResource'.
VERBOSE: Setting configuration of Office 365 Shared Mailbox TTTech Digital Company Calendar
VERBOSE: Dependencies were not already validated.
VERBOSE: Populating RepositorySourceLocation property for module DSCParser.
VERBOSE: Populating RepositorySourceLocation property for module ExchangeOnlineManagement.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\ExchangeOnlineManagement\3.4.0\netCore\ExchangeOnlineManagement.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Applications.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Authentication.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.DeviceManagement.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\Microsoft.Graph.Beta.DeviceManagement\2.19.0\Microsoft.Graph.Beta.DeviceManagement.psm1
'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.Devices.CorporateManagement.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.DeviceManagement.Administration.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\Microsoft.Graph.Beta.DeviceManagement.Administration\2.19.0\Microsoft.Graph.Beta.Device
Management.Administration.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.DeviceManagement.Enrollment.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\Microsoft.Graph.Beta.DeviceManagement.Enrollment\2.19.0\Microsoft.Graph.Beta.DeviceMana
gement.Enrollment.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.Identity.DirectoryManagement.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.Identity.Governance.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.Identity.SignIns.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.Reports.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\Microsoft.Graph.Beta.Reports\2.19.0\Microsoft.Graph.Beta.Reports.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.Teams.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.DeviceManagement.Administration.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\Microsoft.Graph.DeviceManagement.Administration\2.19.0\Microsoft.Graph.DeviceManagement
.Administration.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Beta.DirectoryObjects.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\Microsoft.Graph.Beta.DirectoryObjects\2.19.0\Microsoft.Graph.Beta.DirectoryObjects.psm1
'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Groups.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Planner.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\Microsoft.Graph.Planner\2.19.0\Microsoft.Graph.Planner.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Sites.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\Microsoft.Graph.Sites\2.19.0\Microsoft.Graph.Sites.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Users.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\Microsoft.Graph.Users\2.19.0\Microsoft.Graph.Users.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Users.Actions.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.PowerApps.Administration.PowerShell.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\Microsoft.PowerApps.Administration.PowerShell\2.0.188\Microsoft.PowerApps.Administratio
n.Powershell.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module MicrosoftTeams.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\MicrosoftTeams\6.2.0\MicrosoftTeams.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module MSCloudLoginAssistant.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\MSCloudLoginAssistant\1.1.16\ConnectionProfile.psm1'.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\MSCloudLoginAssistant\1.1.16\Workloads\ExchangeOnline.psm1'.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\MSCloudLoginAssistant\1.1.16\Workloads\MicrosoftGraph.psm1'.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\MSCloudLoginAssistant\1.1.16\Workloads\Teams.psm1'.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\MSCloudLoginAssistant\1.1.16\Workloads\PnP.psm1'.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\MSCloudLoginAssistant\1.1.16\Workloads\PowerPlatform.psm1'.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\MSCloudLoginAssistant\1.1.16\Workloads\SecurityCompliance.psm1'.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\MSCloudLoginAssistant\1.1.16\Workloads\Tasks.psm1'.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\MSCloudLoginAssistant\1.1.16\Workloads\Teams.psm1'.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\MSCloudLoginAssistant\1.1.16\MSCloudLoginAssistant.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module PnP.PowerShell.
VERBOSE: Loading module from path 'C:\Users\*******\Documents\PowerShell\Modules\PnP.PowerShell\1.12.0\Core\PnP.PowerShell.dll'.
VERBOSE: Populating RepositorySourceLocation property for module ReverseDSC.
VERBOSE: Dependencies were all successfully validated.
VERBOSE: Perform operation 'Query CimInstances' with following parameters, ''queryExpression' = SELECT Caption FROM Win32_OperatingSystem,'queryDialect' = WQL,'namespaceN
ame' = root\cimv2'.
VERBOSE: Operation 'Query CimInstances' complete.
VERBOSE: Exporting function 'Get-DscConfiguration'.
VERBOSE: Exporting function 'Get-DscConfigurationStatus'.
VERBOSE: Exporting function 'Get-DscLocalConfigurationManager'.
VERBOSE: Exporting function 'Publish-DscConfiguration'.
VERBOSE: Exporting function 'Restore-DscConfiguration'.
VERBOSE: Exporting function 'Start-DscConfiguration'.
VERBOSE: Exporting function 'Set-DscLocalConfigurationManager'.
VERBOSE: Exporting function 'Test-DscConfiguration'.
VERBOSE: Exporting function 'Update-DscConfiguration'.
VERBOSE: Exporting function 'Configuration'.
VERBOSE: Exporting function 'Disable-DscDebug'.
VERBOSE: Exporting function 'Enable-DscDebug'.
VERBOSE: Exporting function 'Get-DscResource'.
VERBOSE: Exporting function 'New-DscChecksum'.
VERBOSE: Exporting function 'Remove-DscConfigurationDocument'.
VERBOSE: Exporting function 'Stop-DscConfiguration'.
VERBOSE: Exporting function 'Invoke-DscResource'.
VERBOSE: Exporting alias 'gcfg'.
VERBOSE: Exporting alias 'gcfgs'.
VERBOSE: Exporting alias 'glcm'.
VERBOSE: Exporting alias 'pbcfg'.
VERBOSE: Exporting alias 'rtcfg'.
VERBOSE: Exporting alias 'sacfg'.
VERBOSE: Exporting alias 'slcm'.
VERBOSE: Exporting alias 'tcfg'.
VERBOSE: Exporting alias 'upcfg'.
VERBOSE: Getting configuration of Office 365 Shared Mailbox TTTech Digital Company Calendar
VERBOSE: Attempting connection to {ExchangeOnline} with:
VERBOSE:
Name Value
---- -----
TenantId tttech365.onmicrosoft.com
PrimarySMTPAddress tttech-digital-calendar
ApplicationId ****************************
CertificatePath C:/users/*******/Documents/ServiceRequestAutomation-MeetingRooms.pfx
CertificatePassword System.Management.Automation.PSCredential
EmailAddresses {tttech-digital-calendar@tttech365.mail.onmicrosoft.com, tttech-digital-calendar@tttech365.onmicrosoft.com}
DisplayName TTTech Digital Company Calendar
Alias tttech-digital-calendar
Ensure Present
VERBOSE: Initializing the Connected To Workloads List.
VERBOSE: ApplicationId, TenantId, CertificatePath & CertificatePassword were specified. Connecting via Service Principal
VERBOSE: Set environment to {}
VERBOSE: Importing cmdlet 'Clear-ActiveToken'.
VERBOSE: Dependencies were already successfully validated.
VERBOSE: Could not retrieve AAD roledefinition by Id: {}
VERBOSE: The specified Shared Mailbox doesn't already exist.
VERBOSE: Attempting connection to {ExchangeOnline} with:
VERBOSE:
Name Value
---- -----
TenantId tttech365.onmicrosoft.com
PrimarySMTPAddress tttech-digital-calendar
ApplicationId 0ae7484c-ffae-49f2-8165-96190ddb2e93
CertificatePath C:/users/*******/Documents/ServiceRequestAutomation-MeetingRooms.pfx
CertificatePassword System.Management.Automation.PSCredential
EmailAddresses {tttech-digital-calendar@tttech365.mail.onmicrosoft.com, tttech-digital-calendar@tttech365.onmicrosoft.com}
DisplayName TTTech Digital Company Calendar
Alias tttech-digital-calendar
Ensure Present
VERBOSE: ApplicationId, TenantId, CertificatePath & CertificatePassword were specified. Connecting via Service Principal
VERBOSE: Importing cmdlet 'Clear-ActiveToken'.
VERBOSE: Shared Mailbox 'TTTech Digital Company Calendar' does not exist but it should. Creating it.
Set-TargetResource: The term 'New-MailBox' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a
path was included,
verify that the path is correct and try again.
Environment Information + PowerShell Version
PS C:\Users\*******\Documents\PowerShell\service-request-automation> Get-ComputerInfo -Property @(
>> 'OsName',
>> 'OsOperatingSystemSKU',
>> 'OSArchitecture',
>> 'WindowsVersion',
>> 'WindowsBuildLabEx',
>> 'OsLanguage',
>> 'OsMuiLanguages')
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}
PS C:\Users\*******\Documents\PowerShell\service-request-automation>
PS C:\Users\*******\Documents\PowerShell\service-request-automation> $PSVersionTable
Name Value
---- -----
PSVersion 7.4.2
PSEdition Core
GitCommitId 7.4.2
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