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

Running M365 DSC commands in CI pipeline with firewall blocking access to PowerShell Gallery #5740

Open
RosalindHook opened this issue Feb 7, 2025 · 3 comments

Comments

@RosalindHook
Copy link

I am attempting to run Microsoft 365 DSC (M365 DSC) commands within a CI pipeline in GitLab. However, my organization has blocked access to the PowerShell Gallery due to network security policies, and I am unable to set up a proxy to access it.

As a workaround, I downloaded the required DSC modules and pushed them to Artifactory (a remote repository). In the pipeline, I am downloading and unzipping the modules, and then running the following command to import the module:

Import-Module "$modulePath/Microsoft365DSC.psd1"

After successfully importing the module, I attempt to execute the Export-M365DSCConfiguration command using secret credentials. However, I encounter the following error:

Write-Error: Failed to export M365 DSC Configuration: The term 'Connect-M365Tenant' is not recognized as the name of a cmdlet, function, script file, or executable program.

When running the script locally, I would typically use the Update-M365DSCDependencies command to ensure all required dependencies are installed and updated, but this is not possible in my current CI pipeline setup due to the lack of PowerShell Gallery access. I understand that M365DSC relies on several other modules for its functionality, which are likely out of date in my current environment.

Questions/Clarifications:

  1. Is there a way to manually identify which specific modules M365DSC depends on so that I can download and update them independently?
  2. Is it necessary to have the most up-to-date version of M365DSC and all its dependencies to resolve the Connect-M365Tenant error, or is there another potential solution I can implement in my CI pipeline to bypass this issue?
@FabienTschanz
Copy link
Collaborator

@RosalindHook The required modules with their versions for the current version of Microsoft365DSC can be found here: Modules/Microsoft365DSC/Dependencies/Manifest.psd1. If you install the modules in the system context before running any other commands of the Microsoft365DSC module, you should be fine.

@RosalindHook
Copy link
Author

Thank you @FabienTschanz this is really helpful.

I am having a related issue with the dependency PSDesiredStateConfiguration. If I run the command to update all dependencies, everything updates to the versions in the manifest with the exception of PnP.PowerShell. I get this warning:

WARNING: The dependency {PSDesiredStateConfiguration} requires PowerShell Core. Please run Update-M365DSCDependencies
in PowerShell Core.

But I thought the recommendation was to use PowerShell 5.x with DSC? Therefore what should I do about this one dependency requiring a different version?

@FabienTschanz
Copy link
Collaborator

FabienTschanz commented Feb 13, 2025

If you were to use PowerShell 7, you would need to install that module in the PowerShell 7 shell. If you don't use that, you can safely ignore the message. Current suggestion is, as you wrote, PS 5.1.

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

No branches or pull requests

2 participants