Tuesday, July 24, 2018

Microsoft Teams, Visual Studio & PowerShell: Module was not loaded because no valid module file was found in any module directory

Hello world!


I've been working on a small utility to programmatically create new Microsoft Teams sites?teams?rooms?pages?  whatever they're called.  The idea is to accept some parameters from the user, if needed route the request for approval, then create the new site.


Currently, the only programmatic method to create a new Team is with PowerShell.  Works great interactively, so the next step was to see if I could create the new Team using PowerShell invoked from code.  Yeah, not elegant, but so far that's the only option.


I started off creating a new VS Windows solution with the big ol button on there to just run some code - and no dice.  If I ran the same script interactively it worked great, but not from within Visual Studio.  The error received was Module MicrosoftTeams was not loaded because no valid module file was found in any module directory.


The culprit: 32 bit instead of 64 bit.


When I switched VS from 32 bit to 64 bit, no more error, and my Team created as expected.