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

Improve PowerShell 7 support #4916

Merged
merged 5 commits into from
Jul 29, 2024

Conversation

FabienTschanz
Copy link
Contributor

@FabienTschanz FabienTschanz commented Jul 22, 2024

Pull Request (PR) description

This Pull Request attempts to improve the support of PowerShell 7, especially the handling of the PSDesiredStateConfiguration module in version 1.0 with the cmdlet Get-DscResource. In PowerShell 7, the version 1.0 of this module does not return the DSC resources formatted properly. For this to work properly, the version 2.0.7 must be installed.

This PR introduces a new module dependency to PSDesiredStateConfiguration 2.0.7 and installs this one, if PowerShell Core is used. It then loads the cmdlets of this module with the Prefix Pwsh to make sure no naming conflicts happen with version 1.0.
For this prefix to work, the Microsoft365DSC modules using cmdlets of the PSDesiredStateConfiguration module must check which PowerShell version they are running and then use the appropriate cmdlet.

This PR depends on microsoft/DSCParser#50 for the best experience.

This Pull Request (PR) fixes the following issues


```powershell
Install-Module PSDesiredStateConfiguration -Force
Install-Module PSDesiredStateConfiguration -RequiredVersion 2.0.7 -Force
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's either we add it to the manifest and remove this instruction from here, or leave it out of manifest and keep it here. I am afraid we'll end up having different versions listed in documentation and manifest otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, just a moment. Let me rephrase it so we don't have any ambiguity there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, now using Update-M365DSCDependencies -Scope AllUsers, which in itself goes to the manifest and installs the module if it isn't found in the current PowerShell 7 session.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NikCharlebois Can you please have a look at microsoft/DSCParser#50 as well?

@NikCharlebois NikCharlebois merged commit 25649a6 into microsoft:Dev Jul 29, 2024
2 checks passed
@FabienTschanz FabienTschanz deleted the fix/powershell-7-support branch July 29, 2024 20:08
@FabienTschanz FabienTschanz restored the fix/powershell-7-support branch August 1, 2024 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

M365DSCDeltaReport (Compare Configuration files) does not work
2 participants