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

Check for dependencies and import required modules if not already present #21

Closed
NeighborGeek opened this issue Sep 6, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@NeighborGeek
Copy link

Describe the bug
This module depends on some sub-modules of microsoft.graph, but does not seem to check whether those modules are present before using them.

To Reproduce
Steps to reproduce an example issue caused by not checking dependencies

  1. Launch Powershell 7
  2. Import-module Microsoft.Graph.Authentication
  3. connect-mggraph -scope user.readwrite.all
  4. get-unmanagedexternaluser
  5. Command returns error below due to a dependency on 'microsoft.graph.users'
    Unable to find type [Microsoft.Graph.PowerShell.Models.MicrosoftGraphUser1]

Expected behavior
The MSIdentityTools module should check for modules that it depends upon and import those modules if they aren't already. Ideally, this would check for and import only the specific modules or sub-modules required, and not mass import dozens of unnecessary modules by importing the parent microsoft.graph module.
Note that the documentation for the Microsoft.Graph module explicitly recommends against installing the entire microsoft.graph module, and to instead install only the specific sub-modules needed. This would also apply to which modules should be imported.

Consider adding a Requires statement listing the specific modules required. Alternatively, each function could include check for the modules it depends on within the function if the overall MSIdentityTools module would require many modules that most of the functions wouldn't need.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: Windows
  • PowerShell 7.2.6
  • MS Graph SDK PowerShell Module Version 2.0.17
@NeighborGeek NeighborGeek added the bug Something isn't working label Sep 6, 2022
@jazuntee jazuntee self-assigned this Nov 30, 2022
@jazuntee
Copy link
Contributor

@NeighborGeek I have updated all commands that use Mg modules to call the shared Test-MgCommand function so you should get an error now if the required modules cannot be loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants