ConvertFrom-DscObject: Append a new line after each resource#81
Conversation
|
Thank you @ricmestre, will review it once I get home from Seattle. |
|
Hmm, for me it does what is expected, whether it is in Windows PowerShell or in PowerShell 7. How do you get that result? I'm using e.g. the following code, which gives the correct output: PS> ConvertTo-DSCObject -Path 'D:\M365DSC\M365DSC_Data\EXO\M365TenantConfig_EXO.ps1' | ConvertFrom-DSCObject
EXORoleGroup "EXORoleGroup-SecurityReaders_590827472"
{
ApplicationId = $ConfigurationData.NonNodeData.ApplicationId
CertificateThumbprint = $ConfigurationData.NonNodeData.CertificateThumbprint
Description = "Membership in this role group is synchronized across services and managed centrally. This role group is not manageable through the administrator portals. Members of this role group may include cross-service administrators, as well as external partner groups and Microsoft Support. By default, this group may not be assigned any roles. However, it will be a member of the Security Reader role groups and will inherit the capabilities of that role group."
Ensure = "Present"
Members = @()
Name = "SecurityReaders_590827472"
Roles = @()
TenantId = $OrganizationName
}
EXORoleGroup "EXORoleGroup-Nuvolu_M365DSC_Rolegroup_EXO"
{
ApplicationId = $ConfigurationData.NonNodeData.ApplicationId
CertificateThumbprint = $ConfigurationData.NonNodeData.CertificateThumbprint
Description = ""
Ensure = "Present"
Members = @("Sample")
Name = "Sample"
Roles = @(
"Mail Recipients"
"E-Mail Address Policies"
"Federated Sharing"
"Mail Tips"
"Compliance Admin"
"Address Lists"
"Organization Configuration"
"Role Management"
)
TenantId = $OrganizationName
}
EXOSafeAttachmentPolicy "EXOSafeAttachmentPolicy-Standard Preset Security Policy1740412545615"
{
Action = "Block"
AdminDisplayName = ""
ApplicationId = $ConfigurationData.NonNodeData.ApplicationId
CertificateThumbprint = $ConfigurationData.NonNodeData.CertificateThumbprint
Enable = $True
Ensure = "Present"
Identity = "Standard Preset Security Policy1740412545615"
QuarantineTag = "AdminOnlyAccessPolicy"
Redirect = $False
RedirectAddress = ""
TenantId = $OrganizationName
}Edit: Any chance there is a replace of \r\n or something like that happening somewhere in your code? I'm using DSCParser 3.0.0.1 without any changes. |
|
AH! If you pass the objs via a pipeline it works, I just confirmed, but instead try it with Another thing is that $Resources = ConvertTo-DSCObject -Path .\Config\M365Configuration.ps1
ConvertTo-DSCObject : Error parsing DSC configuration: Exception calling "ConvertToDscObject" with "4" argument(s): "Could not find file 'C:\WINDOWS\system32\Config\M365Configuration.ps1'."
`` |
|
Good catches. I'll test the impact of your change and make sure that support for relative paths is added. Appreciate it! |
Currently
ConvertFrom-DscObjectdoesn't append a new line after each resource which results in something like the below so I've just added a one-liner fix to appendEnvironment.NewLinejust right at the end of processing each resource. I've also included a test for this and all tests passed, including mine, withdotnet run