microsoft / Microsoft365DSC

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

How can I change the path for M365DSC-ErrorLog.log. #4289

Open ResearchAndDevelopment00 opened 5 months ago

ResearchAndDevelopment00 commented 5 months ago

While trying to export configuration using Export-M365DSCConfiguration for the TeamsTeam component with GlobalReader privileges, I am getting the following error in a M365DSC-ErrorLog.log file:

[2024-02-06 01:15:39] {InvalidData} System.Management.Automation.ParameterBindingValidationException: Cannot validate argument on parameter 'DisplayName'. The character length (0) of the argument is too short. Specify an argument with a length that is greater than or equal to "1", and then try the command again. ---> System.Management.Automation.ValidationMetadataException: The character length (0) of the argument is too short. Specify an argument with a length that is greater than or equal to "1", and then try the command again. at System.Management.Automation.ValidateLengthAttribute.ValidateElement(Object element) at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags) --- End of inner exception stack trace --- at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) "Error during Export:" at Export-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.103.1\DSCResources\MSFT_TeamsTeam\MSFT_TeamsTeam.psm1: line 705 at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.103.1\modules\M365DSCReverse.psm1: line 639 at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.103.1\modules\M365DSCUtil.psm1: line 1312 at , : line 1

My question is, how can I change the location for the M365DSC-ErrorLog.log files, and how can I resolve this error for the mentioned role?

andikrueger commented 5 months ago

Please check your EntraID for a M365Group without a DisplayName. This is most likely the reason for this issue.

ResearchAndDevelopment00 commented 5 months ago

I am able to export the TeamsTeam component with Global Administration privileges, so I don't think that the absence of a DisplayName would be an issue.

Also, how can I change the location for the M365DSC-ErrorLog.log files?

ricmestre commented 5 months ago

@andikrueger https://microsoft365dsc.com/user-guide/get-started/authentication-and-permissions/ is missing a section about which role is required for Teams workload (along with the API permissions if using an app) and I also don't know exactly which one is required so I've granted Teams Administrator and this one works, looks like Global Reader doesn't.

andikrueger commented 5 months ago

This is a bug within the Teams Resource. The display name property is null and causes an issue within the export logic.

AFAIK, Error log location cannot be changed.

andikrueger commented 5 months ago

@ricmestre did you have a look at this personas article: https://microsoft365dsc.com/concepts/personas/

ricmestre commented 5 months ago

Saw the diffs when it was added but never actually opened the page, looks neat but it doesn't quite answer the question, so you have a Teams Voice Admin that deals with these policies and Collaboration Admin that deals with those other policies, but then on both it's specified that the required role to create/update is always Teams Administrator. I don't have issues with this info, I figured it out myself but someone else might not get there so easily.

But I'm not going to hijack this thread even more :)

ResearchAndDevelopment00 commented 5 months ago

I understood that the Teams Administrator will be able to export the setting but due to the access restriction we can't grant any administrative access so it seems like we need to opt out from exporting the TeamsTeam component for now.

Also, I just wanted to know what would happen if we tried to export the same component twice in a single Export-M365DSCConfiguration command. I tried to do it with the TeamsTeam component and found that it won't create a M365DSC-ErrorLog.log. Not sure if that's a bug or what. I ran the following command with Global Reader privileges:

$password = ConvertTo-SecureString 'xxxxx' -AsPlainText -Force;$credential = New-Object System.Management.Automation.PSCredential ('xxxxx', $password);Import-Module Microsoft365DSC -Force; Export-M365DSCConfiguration -Components @("TeamsTeam","TeamsTeam"}) -Credential $credential -Path .; New-M365DSCReportFromConfiguration -Type JSON -ConfigurationPath ./M365TenantConfig.ps1 -OutputPath ./Report.json