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

Function Convert-M365DscHashtableToString - Enhance formatting #2980

Closed
menswearUK opened this issue Mar 8, 2023 · 1 comment · Fixed by #3059
Closed

Function Convert-M365DscHashtableToString - Enhance formatting #2980

menswearUK opened this issue Mar 8, 2023 · 1 comment · Fixed by #3059
Labels
Core Engine Enhancement New feature or request

Comments

@menswearUK
Copy link
Contributor

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

Suggested enhancement to the function Convert-M365DscHashtableToString in M365DSCUtil.psm1.
When calling the function the output is returned as a string with values separated by a semicolon.
This can be somewhat difficult to read - My suggestion is to return the output with each value on a new line, this could either be the default behaviour or selected via a switch.

Verbose logs showing the problem

output of target values from a DSC resource:

Target Values: AllowedDataStorageLocations=(); AllowedInboundDataTransferSources=allApps;
AllowedOutboundClipboardSharingExceptionLength=0; AllowedOutboundClipboardSharingLevel=managedAppsWithPasteIn;
AllowedOutboundDataTransferDestinations=allApps; AppActionIfDeviceComplianceRequired=block;
AppActionIfIosDeviceModelNotAllowed=block; AppActionIfMaximumPinRetriesExceeded=block;
AppDataEncryptionType=whenDeviceLocked; ApplicationId=; ApplicationSecret=;
Apps=(com.microsoft.bing.halseyassistant,com.microsoft.d365.fs.mobile,com.microsoft.dynamics,com.microsoft.dynamics.inv
oice,com.microsoft.dynamics.iphone.moca,com.microsoft.dynamics.iphone.moca.fieldservices,com.microsoft.dynamics.iphone.
moca.sales,com.microsoft.lync2013.iphone,com.microsoft.mobile.polymer,com.microsoft.msapps,com.microsoft.msedge,com.mic
rosoft.o365shdmobileapp,com.microsoft.office.excel,com.microsoft.office.outlook,com.microsoft.office.powerpoint,com.mic
rosoft.office.word,com.microsoft.office365booker,com.microsoft.officelens,com.microsoft.officemobile,com.microsoft.onen
ote,com.microsoft.plannermobile,com.microsoft.powerbimobile,com.microsoft.procsimo,com.microsoft.ramobile,com.microsoft
.rms-sharing,com.microsoft.scmx,com.microsoft.sharepoint,com.microsoft.shiftr,com.microsoft.skydrive,com.microsoft.skyp
e.teams,com.microsoft.splists,com.microsoft.stream,com.microsoft.to-do,com.microsoft.visio,com.microsoft.whiteboard,com
.microsoft.workfolders,com.veradocs.ios.appstore.intune,wefwef); Assignments=(); ContactSyncBlocked=False;
CustomBrowserProtocol=; DataBackupBlocked=False; Description=some descriptive words to describe the policy in the
description. indescribable; DeviceComplianceRequired=True; DisableAppPinIfDevicePinIsSet=False;
DisableProtectionOfManagedOutboundOpenInData=False; DisplayName=testiospolicy; Ensure=Present; ExcludedGroups=();
ExemptedAppProtocols=(Default:skype;app-settings;calshow;itms;itmss;itms-apps;itms-appss;itms-services;);
FaceIdBlocked=False; FilterOpenInToOnlyManagedApps=False; FingerprintBlocked=False; ManagedBrowser=notConfigured; ManagedBrowserToOpenLinksRequired=False;
ManagedIdentity=False; MaximumPinRetries=5; MinimumPinLength=4; NotificationRestriction=allow;
OrganizationalCredentialsRequired=False; PeriodBeforePinReset=90.00:00:00; PeriodOfflineBeforeAccessCheck=12:00:00;
PeriodOfflineBeforeWipeIsEnforced=90.00:00:00; PeriodOnlineBeforeAccessCheck=00:30:00; PinCharacterSet=numeric;
PinRequired=True; PinRequiredInsteadOfBiometricTimeout=00:30:00; PrintBlocked=False;
ProtectInboundDataFromUnknownSources=False; SaveAsBlocked=False; SimplePinBlocked=True;
TargetedAppManagementLevels=unmanaged; TenantId=***; Verbose=True

Suggested solution to the issue

Suggested fix is to replace the final line of the Convert-M365DscHashtableToString function from:
return ($values -join '; ')
to:
return ($values -join "rn")

If both options may be required the different output could be activated via a -newline switch added to the function

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

n/a - any configuration using the function will produce this output although the example was using IntuneAppProtectionPolicyiOS

The operating system the target node is running

n/a - cloud configuration - run from various windows 10 systems when testing

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

dev

@andikrueger andikrueger added Enhancement New feature or request Core Engine labels Mar 9, 2023
@menswearUK
Copy link
Contributor Author

@ykuijs - This was something I'd added to a configuration in a previous PR and you advised it would be better to add in centrally.
I wondered if you had any preference on whether I should amend the default behaviour of the function or, to minimise any possible unforeseen impact, I should modify the output via a switch?
I don't think there are any uses of the function in the configurations which are not part of a verbose output but it's called a lot and I may have missed something in my searches.
It does self reference itself and is also called in Convert-M365DscArrayToString, I'm not sure if there might be any impact here, There hasn't been in my testing but that's far from exhaustive.

menswearUK added a commit to menswearUK/Microsoft365DSC that referenced this issue Mar 21, 2023
menswearUK added a commit to menswearUK/Microsoft365DSC that referenced this issue Mar 22, 2023
ykuijs added a commit that referenced this issue Mar 22, 2023
…ring-formatting-#2980

Convert-m365DscHashtableToString formatting - fixes #2980
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Engine Enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants