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

M365TenantConfig.PS1 Unexpected token if displayname contains ' or , #3479

Closed
ChrisJay77 opened this issue Jul 17, 2023 · 12 comments · Fixed by #3677 or #3682
Closed

M365TenantConfig.PS1 Unexpected token if displayname contains ' or , #3479

ChrisJay77 opened this issue Jul 17, 2023 · 12 comments · Fixed by #3677 or #3682
Labels
Bug Something isn't working Core Engine Pending Information V1.23.712.1 Version 1.23.712.1

Comments

@ChrisJay77
Copy link

Details of the scenario you tried and the problem that is occurring

exporting the config of tenant using the following command:
.\M365TenantConfig.ps1
At C:\ll2_july2023\M365TenantConfig.ps1:1294 char:44

  •                     DisplayName = 'Don’t allow Dynamic Data Excha ...
    
  •                                        ~
    

Unexpected token 't' in expression or statement.
At C:\ll2_july2023\M365TenantConfig.ps1:1294 char:44

  •                     DisplayName = 'Don’t allow Dynamic Data Excha ...
    
  •                                        ~
    

There is an incomplete property assignment block in the instance definition.
At C:\ll2_july2023\M365TenantConfig.ps1:1294 char:43

  •                     DisplayName = 'Don’t allow Dynamic Data Excha ...
    
  •                                       ~
    

There is an incomplete property assignment block in the instance definition.
At C:\ll2_july2023\M365TenantConfig.ps1:1452 char:21

  •                 }
    
  •                 ~
    

Missing closing ')' in subexpression.
At C:\ll2_july2023\M365TenantConfig.ps1:1814 char:44

  •                     DisplayName = 'Don't show the option to trans ...
    
  •                                        ~
    

Unexpected token 't' in expression or statement.
At C:\ll2_july2023\M365TenantConfig.ps1:1814 char:44

  •                     DisplayName = 'Don't show the option to trans ...
    
  •                                        ~
    

There is an incomplete property assignment block in the instance definition.
At C:\ll2_july2023\M365TenantConfig.ps1:1814 char:43

  •                     DisplayName = 'Don't show the option to trans ...
    
  •                                       ~
    

There is an incomplete property assignment block in the instance definition.
At C:\ll2_july2023\M365TenantConfig.ps1:2091 char:17

  •             }
    
  •             ~
    

Unexpected token '}' in expression or statement.
At C:\ll2_july2023\M365TenantConfig.ps1:2382 char:85

  • ... CategoryPath = '\Microsoft Office 2016\Smart Documents (Word, Excel)'
  •                                                             ~
    

Missing argument in parameter list.
At C:\ll2_july2023\M365TenantConfig.ps1:4269 char:101

  • ... \Microsoft Office 2016\Tools | AutoCorrect Options... (Excel, PowerPo ...
  •                                                             ~
    

Missing argument in parameter list.
Not all parse errors were reported. Correct the reported errors and try again.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken

Verbose logs showing the problem

.\M365TenantConfig.ps1
At C:\ll2_july2023\M365TenantConfig.ps1:1294 char:44

  •                     DisplayName = 'Don’t allow Dynamic Data Excha ...
    
  •                                        ~
    

Unexpected token 't' in expression or statement.
At C:\ll2_july2023\M365TenantConfig.ps1:1294 char:44

  •                     DisplayName = 'Don’t allow Dynamic Data Excha ...
    
  •                                        ~
    

There is an incomplete property assignment block in the instance definition.
At C:\ll2_july2023\M365TenantConfig.ps1:1294 char:43

  •                     DisplayName = 'Don’t allow Dynamic Data Excha ...
    
  •                                       ~
    

There is an incomplete property assignment block in the instance definition.
At C:\ll2_july2023\M365TenantConfig.ps1:1452 char:21

  •                 }
    
  •                 ~
    

Missing closing ')' in subexpression.
At C:\ll2_july2023\M365TenantConfig.ps1:1814 char:44

  •                     DisplayName = 'Don't show the option to trans ...
    
  •                                        ~
    

Unexpected token 't' in expression or statement.
At C:\ll2_july2023\M365TenantConfig.ps1:1814 char:44

  •                     DisplayName = 'Don't show the option to trans ...
    
  •                                        ~
    

There is an incomplete property assignment block in the instance definition.
At C:\ll2_july2023\M365TenantConfig.ps1:1814 char:43

  •                     DisplayName = 'Don't show the option to trans ...
    
  •                                       ~
    

There is an incomplete property assignment block in the instance definition.
At C:\ll2_july2023\M365TenantConfig.ps1:2091 char:17

  •             }
    
  •             ~
    

Unexpected token '}' in expression or statement.
At C:\ll2_july2023\M365TenantConfig.ps1:2382 char:85

  • ... CategoryPath = '\Microsoft Office 2016\Smart Documents (Word, Excel)'
  •                                                             ~
    

Missing argument in parameter list.
At C:\ll2_july2023\M365TenantConfig.ps1:4269 char:101

  • ... \Microsoft Office 2016\Tools | AutoCorrect Options... (Excel, PowerPo ...
  •                                                             ~
    

Missing argument in parameter list.
Not all parse errors were reported. Correct the reported errors and try again.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken

Suggested solution to the issue

Please can you allow for the displayname to contain any characters that will not stop the localhost.mof being created?

The DSC configuration that is used to reproduce the issue (as detailed as possible)

# insert configuration here

The operating system the target node is running

Version of the DSC module that was used ('dev' if using current dev branch)

1.23.517.1 i've updated to 1.23.712.1 and still have the same issue

@andikrueger andikrueger added Bug Something isn't working Core Engine V1.23.712.1 Version 1.23.712.1 labels Jul 19, 2023
@andikrueger
Copy link
Collaborator

This is a challenging one. Within M365DSC there is no escaping of characters that might break the configuration. This is something we should look at. For now, I would recommend, to run search/replace within the configuration to add proper escaping to these values.

@NikCharlebois
Copy link
Collaborator

Actually, what resource is exhibiting this behavior (e.g., AADApplication, TeamsMeetingPolicy, etc.) We should be able to handle this inside the resource itself. Thanks

@ztrhgf
Copy link

ztrhgf commented Jul 31, 2023

Same behavior for Intune MSFT_IntuneGroupPolicyDefinitionValue

image

And solution is quite easy, just replace ' for ''

@ChrisJay77
Copy link
Author

@z

Same behavior for Intune MSFT_IntuneGroupPolicyDefinitionValue

image

And solution is quite easy, just replace ' for ''

That's fine if it's a small export but going through 32,759 lines of the m365tenant.ps1 powershell every time you do an export makes it unusable and unfortunately not a solution. I've just done another export for the workload "intune" and the modules affected are: MSFT_IntuneGroupPolicyDefinitionValue and is limited to:
displayname
presentationDefinitionLabel

@ztrhgf
Copy link

ztrhgf commented Aug 3, 2023

I didn't mean that you should do this manually. It was meant for developers :D

@ChrisJay77
Copy link
Author

Actually, what resource is exhibiting this behavior (e.g., AADApplication, TeamsMeetingPolicy, etc.) We should be able to handle this inside the resource itself. Thanks

I've updated to the latest version 1.23.809.1 (it has fixed the exporting when using the app secret) and still have the same issue once exported. please see above comment as it's almost unusable when i'm planning on doing an export every time a change has been done to the environment. Thanks

@Ngims
Copy link

Ngims commented Aug 24, 2023

I am facing similar issue.
Host: is a Windows Server 2019 machine
Version of DSC Module being used is 1.23.809.1
PowerShell
PnP.PowerShell version 1.12.0
PS C:\M365DSC> $PSVersionTable.PSVersion

Major Minor Build Revision


5 1 17763 1971

I did an export of the following components
Export-M365DSCConfiguration -Components @("AADAdministrativeUnit", "AADGroupsSettings", "SPOAccessControlSettings", "SPOApp", "SPOBrowserIdleSignout", "SPOSharingSettings") -Credential $SourceCredential

Exporting the config of tenant using the following command: .\M365TenantConfig.ps1 -Credential $TargetCredential throws below error:

At C:\M365DSC\M365TenantConfig.ps1:115 char:63

  •         SharingDomainRestrictionMode               = "None";
    
  •                                                           ~~
    

The string is missing the terminator: ".
At C:\M365DSC\M365TenantConfig.ps1:62 char:28

  •     AADGroupsSettings "AADGroupsSettings"
    
  •                        ~~~~~~~~~~~~~~~~~~
    

Unexpected token 'AADGroupsSettings"
{
AllowGuestsToAccessGroups = $True;
AllowGuestsToBeGroupOwner = $False;
AllowToAddGuests = $True;
Credential = $Credscredential;
EnableGroupCreation = $False;
Ensure = "Present";
GuestUsageGuidelinesUrl = "";
IsSingleInstance = "Yes";
UsageGuidelinesUrl = "";
}
SPOAccessControlSettings "SPOAccessControlSettings"
{
CommentsOnSitePagesDisabled = $True;
Credential = $Credscredential;
DisallowInfectedFileDownload = $False;
DisplayStartASiteOption = $False;
EmailAttestationReAuthDays = 30;
EmailAttestationRequired = $False;
Ensure = "Present";
ExternalServicesEnabled = $True;
IPAddressAllowList = "";
IPAddressEnforcement = $False;
IPAddressWACTokenLifetime = 15;
IsSingleInstance = "Yes";
SocialBarOnSitePagesDisabled = $False;
}
SPOBrowserIdleSignout "SPOBrowserIdleSignout"
{
Credential = $Credscredential;
Enabled = $True;
IsSingleInstance = "Yes";
SignOutAfter = "1.00:00:00";
WarnAfter = "23:30:00";
}
SPOSharingSettings "SPOSharingSettings"
{
BccExternalSharingInvitations = $False;
Credential = $Credscredential;
DefaultLinkPermission = "View";
DefaultSharingLinkType = "AnonymousAccess";
EnableGuestSignInAcceleration = $False;
Ensure = "Present";
FileAnonymousLinkType = "Edit";
FolderAnonymousLinkType = "Edit";
IsSingleInstance = "Yes";
MySiteSharingCapability = "ExternalUserAndGuestSharing";
NotifyOwnersWhenItemsReshared = $True;
PreventExternalUsersFromResharing = $False;
ProvisionSharedWithEveryoneFolder = $False;
RequireAcceptingAccountMatchInvitedAccount = $True;
SharingCapability = "ExternalUserAndGuestSharing";
SharingDomainRestrictionMode = "None";
ShowAllUsersClaim = $False;
ShowEveryoneClaim = $False;
ShowEveryoneExceptExternalUsersClaim = $True;
ShowPeoplePickerSuggestionsForGuestUsers = $False;
}
}
}
M365TenantConfig -ConfigurationData .\ConfigurationData.psd1 -Credential $Credential
' in expression or statement.
At C:\M365DSC\M365TenantConfig.ps1:125 char:2
+
Missing closing ')' in subexpression.
At C:\M365DSC\M365TenantConfig.ps1:125 char:1
+
There is an incomplete property assignment block in the instance definition.
At C:\M365DSC\M365TenantConfig.ps1:33 char:5

  • {
    
  • ~
    

Missing closing '}' in statement block or type definition.
At C:\M365DSC\M365TenantConfig.ps1:10 char:1

  • {
  • ~
    Missing closing '}' in statement block or type definition.
    • CategoryInfo : ParserError: (:) [], ParseException
    • FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
      M365TenantConfig.zip

@ricmestre
Copy link
Contributor

@Ngims Hi, that is a different issue happening on ReverseDSC module, please raise a separate issue for this and attach your config file again as well.

@Ngims
Copy link

Ngims commented Aug 25, 2023

@ricmestre thanks for the response. Will do as requested.

NikCharlebois added a commit to NikCharlebois/Microsoft365DSC that referenced this issue Sep 12, 2023
@ChrisJay77
Copy link
Author

I'm still having the same issue using the current release
ModuleBase Version


C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.1004.1 1.23.1004.1
export errors.txt

once i've changed the displayname form ' to " i still can't get a full export as getting other errors about telemetry (i did # out the line) then errors about having the & in the name. I've attached a copy of the errors. PLease can you look into this as i cannot get a complete working mof created. Thanks

@ztrhgf
Copy link

ztrhgf commented Oct 9, 2023

I gave it up and using EntraExporter now :D

@ChrisJay77
Copy link
Author

I've revisited this and have changed all the non-standard displaynames (20 profiles) and i'm almost at the point where i can do a full export!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Core Engine Pending Information V1.23.712.1 Version 1.23.712.1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants