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

MSFT_EXOMailboxCalendarFolder.psm1: optimize/extend - calendar code not language-resistant #4056

Closed
bjbakker1984 opened this issue Dec 15, 2023 · 0 comments · Fixed by #4085 or #4101
Closed
Assignees
Labels
Bug Something isn't working Exchange Online

Comments

@bjbakker1984
Copy link

Description of the issue

code uses the fixed "calendar" text as primary calendar to check.
This is not the default name in languages other than English.

Code:

$folderPath = $mailbox.UserPrincipalName + ':\Calendar'

Proposed optimization (replace codeline):

        $CalendarName=($CalendarFolder=Get-MailboxFolderStatistics -Identity $mailbox.UserPrincipalName -FolderScope Calendar | Where-Object {$_.FolderType -eq 'Calendar'} | Select-Object Name).Name
        $folderPath = $mailbox.UserPrincipalName + ':\' + $CalendarName

Microsoft 365 DSC Version

1.23.1213.1

Which workloads are affected

Exchange Online

The DSC configuration

No response

Verbose logs showing the problem

PS>TerminatingError(Invoke-WebRequest): "{"error":{"code":"InternalServerError","message":"Error executing cmdlet","details":[{"code":"ServerOperation","target":"","message":"{\"ClassName\":\"Microsoft.Exchange.Configuration.CmdletProxyException\",\"Message\":\"Error on proxy command 'Get-MailboxCalendarFolder -ErrorAction:'SilentlyContinue' -Identity:'************:\\\\Calendar'' to server ************: Server version 15.20.7091.0000, Proxy method PSWS: \\r\\nInternalServerError: Error executing cmdlet : {\\r\\n  \\\"code\\\": \\\"InternalServerError\\\",\\r\\n  \\\"message\\\": \\\"Error executing cmdlet\\\",\\r\\n  \\\"details\\\": [\\r\\n    {\\r\\n      \\\"code\\\": \\\"0\\\",\\r\\n      \\\"target\\\": \\\"\\\",\\r\\n      \\\"message\\\": \\\"|Microsoft.Exchange.Data.Storage.CantFindCalendarFolderException|Er is geen agendamap die overeenkomt met ************:\\\\\\\\Calendar. Controleer of u de juiste naam van de agendamap hebt opgegeven.\\\"\\r\\n    }\\r\\n  ],\\r\\n  \\\"innererror\\\": {\\r\\n    \\\"message\\\": \\\"Error executing cmdlet\\\",\\r\\n    \\\"type\\\": \\\"Microsoft.Exchange.Admin.OData.Core.ODataServiceException\\\",\\r\\n    \\\"stacktrace\\\": \\\"   at Microsoft.Exchange.AdminApi.CommandInvocation.CommandInvocation.InvokeCommand(QueryContext queryContext, CmdletInvokeInputType cmdletInvokeInputType)\\\\r\\\\n   at Microsoft.Exchange.Admin.OData.Core.PathSegmentToExpressionTranslator.Translate(OperationImportSegment segment)\\\\r\\\\n   at Microsoft.Exchange.Admin.OData.Core.QueryContext.ResolveQuery(ODataContext context, Int32 level)\\\\r\\\\n   at Microsoft.Exchange.Admin.OData.Core.Handlers.OperationHandler.Process(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage)\\\\r\\\\n   at Microsoft.Exchange.Admin.OData.Core.Handlers.RequestHandler.Process(Stream requestStream)\\\",\\r\\n    \\\"internalexception\\\": {\\r\\n      \\\"message\\\": \\\"Exception of type 'Microsoft.Exchange.Management.PSDirectInvoke.DirectInvokeCmdletExecutionException' was thrown.\\\",\\r\\n      \\\"type\\\": \\\"Microsoft.Exchange.Management.PSDirectInvoke.DirectInvokeCmdletExecutionException\\\",\\r\\n      \\\"stacktrace\\\": \\\"   at Microsoft.Exchange.Management.PSDirectInvoke.PSDirectInvokeCmdletFactory.InvokeCmdletInternal[TCmdlet,TResult](Func`1 createCmdlet, Action`1 setParameterDelegate, List`1 captureAdditionalIO, List`1 directInvokeExceptions, Boolean shouldAllowProactiveProxyToReturnRoutingHint)\\\"\\r\\n    }\\r\\n  },\\r\\n  \\\"adminapi.warnings@odata.type\\\": \\\"#Collection(String)\\\",\\r\\n  \\\"@adminapi.warnings\\\": []\\r\\n} [Server=************,TimeStamp=15-12-2023 22:19:12] .\",\"Data\":null,\"InnerException\":null,\"HelpURL\":null,\"StackTraceString\":\"\",\"RemoteStackTraceString\":null,\"RemoteStackIndex\":0,\"ExceptionMethod\":\"8\\nThrowError\\nMicrosoft.Exchange.Configuration.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=************\\nMicrosoft.Exchange.Configuration.Tasks.Task\\nVoid ThrowError(System.Exception, System.Management.Automation.ErrorCategory, System.Object, System.String)\",\"HResult\":-2146233088,\"Source\":\"Microsoft.Exchange.Configuration.ObjectModel\",\"WatsonBuckets\":null,\"localizedString\":{\"inserts\":[\"Get-MailboxCalendarFolder -ErrorAction:'SilentlyContinue' -Identity:'************:\\\\Calendar'\",\"************\",\"15.20.7091.0000\",\"PSWS\",\"InternalServerError: Error executing cmdlet : {\\r\\n  \\\"code\\\": \\\"InternalServerError\\\",\\r\\n  \\\"message\\\": \\\"Error executing cmdlet\\\",\\r\\n  \\\"details\\\": [\\r\\n    {\\r\\n      \\\"code\\\": \\\"0\\\",\\r\\n      \\\"target\\\": \\\"\\\",\\r\\n      \\\"message\\\": \\\"|Microsoft.Exchange.Data.Storage.CantFindCalendarFolderException|Er is geen agendamap die overeenkomt met ************:\\\\\\\\Calendar. Controleer of u de juiste naam van de agendamap hebt opgegeven.\\\"\\r\\n    }\\r\\n  ],\\r\\n  \\\"innererror\\\": {\\r\\n    \\\"message\\\": \\\"Error executing cmdlet\\\",\\r\\n    \\\"type\\\": \\\"Microsoft.Exchange.Admin.OData.Core.ODataServiceException\\\",\\r\\n    \\\"stacktrace\\\": \\\"   at Microsoft.Exchange.AdminApi.CommandInvocation.CommandInvocation.InvokeCommand(QueryContext queryContext, CmdletInvokeInputType cmdletInvokeInputType)\\\\r\\\\n   at Microsoft.Exchange.Admin.OData.Core.PathSegmentToExpressionTranslator.Translate(OperationImportSegment segment)\\\\r\\\\n   at Microsoft.Exchange.Admin.OData.Core.QueryContext.ResolveQuery(ODataContext context, Int32 level)\\\\r\\\\n   at Microsoft.Exchange.Admin.OData.Core.Handlers.OperationHandler.Process(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage)\\\\r\\\\n   at Microsoft.Exchange.Admin.OData.Core.Handlers.RequestHandler.Process(Stream requestStream)\\\",\\r\\n    \\\"internalexception\\\": {\\r\\n      \\\"message\\\": \\\"Exception of type 'Microsoft.Exchange.Management.PSDirectInvoke.DirectInvokeCmdletExecutionException' was thrown.\\\",\\r\\n      \\\"type\\\": \\\"Microsoft.Exchange.Management.PSDirectInvoke.DirectInvokeCmdletExecutionException\\\",\\r\\n      \\\"stacktrace\\\": \\\"   at Microsoft.Exchange.Management.PSDirectInvoke.PSDirectInvokeCmdletFactory.InvokeCmdletInternal[TCmdlet,TResult](Func`1 createCmdlet, Action`1 setParameterDelegate, List`1 captureAdditionalIO, List`1 directInvokeExceptions, Boolean shouldAllowProactiveProxyToReturnRoutingHint)\\\"\\r\\n    }\\r\\n  },\\r\\n  \\\"adminapi.warnings@odata.type\\\": \\\"#Collection(String)\\\",\\r\\n  \\\"@adminapi.warnings\\\": []\\r\\n} [Server=************,TimeStamp=15-12-2023 22:19:12] \"],\"baseName\":\"Microsoft.Exchange.Configuration.Common.LocStrings.Strings\",\"assemblyName\":\"Microsoft.Exchange.Configuration.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=************\",\"id\":\"ErrorCmdletProxy\",\"stringId\":\"\",\"showStringIdInUIIfError\":false,\"showAssistanceInfoInUIIfError\":false,\"fallback\":\"Error on proxy command '{0}' to server {1}: Server version {2}, Proxy method {3}: \\r\\n{4}.\"},\"command\":\"Get-MailboxCalendarFolder -ErrorAction:'SilentlyContinue' -Identity:'************:\\\\Calendar'\",\"serverFqn\":\"************\",\"serverVersion\":\"15.20.7091.0000\",\"proxyMethod\":\"PSWS\",\"errorMessage\":\"InternalServerError: Error executing cmdlet : {\\r\\n  \\\"code\\\": \\\"InternalServerError\\\",\\r\\n  \\\"message\\\": \\\"Error executing cmdlet\\\",\\r\\n  \\\"details\\\": [\\r\\n    {\\r\\n      \\\"code\\\": \\\"0\\\",\\r\\n      \\\"target\\\": \\\"\\\",\\r\\n      \\\"message\\\": \\\"|Microsoft.Exchange.Data.Storage.CantFindCalendarFolderException|Er is geen agendamap die overeenkomt met ************:\\\\\\\\Calendar. Controleer of u de juiste naam van de agendamap hebt opgegeven.\\\"\\r\\n    }\\r\\n  ],\\r\\n  \\\"innererror\\\": {\\r\\n    \\\"message\\\": \\\"Error executing cmdlet\\\",\\r\\n    \\\"type\\\": \\\"Microsoft.Exchange.Admin.OData.Core.ODataServiceException\\\",\\r\\n    \\\"stacktrace\\\": \\\"   at Microsoft.Exchange.AdminApi.CommandInvocation.CommandInvocation.InvokeCommand(QueryContext queryContext, CmdletInvokeInputType cmdletInvokeInputType)\\\\r\\\\n   at Microsoft.Exchange.Admin.OData.Core.PathSegmentToExpressionTranslator.Translate(OperationImportSegment segment)\\\\r\\\\n   at Microsoft.Exchange.Admin.OData.Core.QueryContext.ResolveQuery(ODataContext context, Int32 level)\\\\r\\\\n   at Microsoft.Exchange.Admin.OData.Core.Handlers.OperationHandler.Process(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage)\\\\r\\\\n   at Microsoft.Exchange.Admin.OData.Core.Handlers.RequestHandler.Process(Stream requestStream)\\\",\\r\\n    \\\"internalexception\\\": {\\r\\n      \\\"message\\\": \\\"Exception of type 'Microsoft.Exchange.Management.PSDirectInvoke.DirectInvokeCmdletExecutionException' was thrown.\\\",\\r\\n      \\\"type\\\": \\\"Microsoft.Exchange.Management.PSDirectInvoke.DirectInvokeCmdletExecutionException\\\",\\r\\n      \\\"stacktrace\\\": \\\"   at Microsoft.Exchange.Management.PSDirectInvoke.PSDirectInvokeCmdletFactory.InvokeCmdletInternal[TCmdlet,TResult](Func`1 createCmdlet, Action`1 setParameterDelegate, List`1 captureAdditionalIO, List`1 directInvokeExceptions, Boolean shouldAllowProactiveProxyToReturnRoutingHint)\\\"\\r\\n    }\\r\\n  },\\r\\n  \\\"adminapi.warnings@odata.type\\\": \\\"#Collection(String)\\\",\\r\\n  \\\"@adminapi.warnings\\\": []\\r\\n} [Server=************,TimeStamp=15-12-2023 22:19:12] \"}"}],"innererror":{"message":"Error executing cmdlet","type":"Microsoft.Exchange.Admin.OData.Core.ODataServiceException","stacktrace":"   at Microsoft.Exchange.AdminApi.CommandInvocation.CommandInvocation.InvokeCommand(QueryContext queryContext, CmdletInvokeInputType cmdletInvokeInputType)\r\n   at Microsoft.Exchange.Admin.OData.Core.PathSegmentToExpressionTranslator.Translate(OperationImportSegment segment)\r\n   at Microsoft.Exchange.Admin.OData.Core.QueryContext.ResolveQuery(ODataContext context, Int32 level)\r\n   at Microsoft.Exchange.Admin.OData.Core.Handlers.OperationHandler.Process(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage)\r\n   at Microsoft.Exchange.Admin.OData.Core.Handlers.RequestHandler.Process(Stream requestStream)","internalexception":{"message":"Exception of type 'Microsoft.Exchange.Management.PSDirectInvoke.DirectInvokeCmdletExecutionException' was thrown.","type":"Microsoft.Exchange.Management.PSDirectInvoke.DirectInvokeCmdletExecutionException","stacktrace":"   at Microsoft.Exchange.Management.PSDirectInvoke.PSDirectInvokeCmdletFactory.InvokeCmdletInternal[TCmdlet,TResult](Func`1 createCmdlet, Action`1 setParameterDelegate, List`1 captureAdditionalIO, List`1 directInvokeExceptions, Boolean shouldAllowProactiveProxyToReturnRoutingHint)"}},"adminapi.warnings@odata.type":"#Collection(String)","@adminapi.warnings":[]}}"

Environment Information + PowerShell Version

OsName               : Microsoft Windows 11 Pro
OsOperatingSystemSKU : 48
OsArchitecture       : 64 bits
WindowsVersion       : 2009
WindowsBuildLabEx    : 22621.1.amd64fre.ni_release.220506-1250
OsLanguage           : nl-NL
OsMuiLanguages       : {nl-NL}

Key   : PSVersion
Value : 5.1.22621.2506
Name  : PSVersion

Key   : PSEdition
Value : Desktop
Name  : PSEdition

Key   : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0...}
Name  : PSCompatibleVersions

Key   : BuildVersion
Value : 10.0.22621.2506
Name  : BuildVersion

Key   : CLRVersion
Value : 4.0.30319.42000
Name  : CLRVersion

Key   : WSManStackVersion
Value : 3.0
Name  : WSManStackVersion

Key   : PSRemotingProtocolVersion
Value : 2.3
Name  : PSRemotingProtocolVersion

Key   : SerializationVersion
Value : 1.1.0.1
Name  : SerializationVersion
@bjbakker1984 bjbakker1984 changed the title MSFT_EXOMailboxCalendarFolder.psm1: optimize - calendar code not language-resistant MSFT_EXOMailboxCalendarFolder.psm1: optimize/extend - calendar code not language-resistant Dec 16, 2023
@malauter malauter self-assigned this Dec 21, 2023
@malauter malauter added Bug Something isn't working Exchange Online labels Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Exchange Online
Projects
None yet
2 participants