Make PowerShell able to enable logging of script block execution on Unix platforms#5791
Merged
daxian-dbw merged 13 commits intoPowerShell:masterfrom Jan 8, 2018
Merged
Make PowerShell able to enable logging of script block execution on Unix platforms#5791daxian-dbw merged 13 commits intoPowerShell:masterfrom
daxian-dbw merged 13 commits intoPowerShell:masterfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Fix #5695
Enable ScriptBlockLogging on Linux/macOS by moving the GroupPolicy configurations to the configuration file
PowerShellProperties.json. Including the following tasks:MshLog.cson Unix platforms. (the 1st commit)PropertyAccessor.cs. (the 2nd commit)PowerShellConfigPowerShellConfigto the namespaceSystem.Management.Automation.ConfigurationPropertyScopetoConfigScope. (the 3rd commit)PropertyAccessor.cstoPSConfiguration.cs. (the 4th commit)SecuritySupport.cs)CompiledScriptBlock.cs)ModuleCmdletBase.cs)CompiledScriptBlock.cs)MshHostUserInterface.cs)UpdatableHelpSystem.cs)CommandLineParameterParser.cs)PSConfiguration.cs, updatedReadValueFromFile<T>to make it flexible to allow a customJsonObjectparsing implementation delegate passed in.PSConfiguration.cs, addedGetPowerShellPolicies(ConfigScope scope)and makeDefaultSourcePathsetting part of the new policy settings because it is part of the group policy on windows powershell.Utils.cs, replace the methodGetGroupPolicySettingwithT GetPolicySetting<T>(ConfigScope[] preferenceOrder) where T : PolicyBase. The old method was for reading from Registry, while the new one is for reading from configuration file.GetGroupPolicySettingbeing replaced.PSTests.Paralleland the new tests are moved toPSTests.Sequentialand the corresponding build scripts are updated to run sequential xUnit tests first and then run other xUnit tests in parallel.SysLogProviderto make ScriptBlock logging not ignored on Unix platforms. (the 7th commit)PowerShellProperties.jsontopowershell.config.json. (the 10th commit)An example of the configuration file
powershell.config.jsonLimitation that needs to be documented
On Unix platform, the default logging level filter is
information, while the logging of script block execution writes outverboselevel logging. So the configuration entry"LogLevel": "verbose"is needed along with the settings in"ScriptBlockLogging". This needs to be documented.Documentation needed
We need documentation to clarify how logging works in PowerShell. Not sure if we already have some docs about it. Issue MicrosoftDocs/PowerShell-Docs#2017 is opened.
PR Checklist
Note: Please mark anything not applicable to this PR
NA.[feature]if the change is significant or affectes feature testsWIP:to the beginning of the title and remove the prefix when the PR is ready.