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.

Monday, March 19, 2018

SP json conditional formatting

Hi world!  Yes it has been a while indeed...but finally something to give back!

My customer asked to have SharePoint Online views formatted such that the font color for certain rows would be different based on the Status field value for the list item.  Since we're using SPO I did not want to go the custom column formatter route, and I found a reference for using JSON for column formatting - but no great examples.

The only wrinkle I found is this is done at the field level - so wherever this field is used in a list, it will include this formatting.  Fortunately not an issue in my case, but you might have a case where you want the field to retain its default formatting.

{
    "elmType": "div",
    "txtContent": "@currentField",
    "style": {
       "color": {
          "operator": "?",
          "operands": [
             {
                "operator": "==",
                "operands": [
                   "[$processStatus]",
                   "Inactive"
                ]
             },
             "#a9a9a9",
             ""
          ]
       }
    }
 }

My status field is processStatus (case matters).  And in my case I want to change the color to a dark gray, if the status is equal to 'Inactive'. 

The result:


Success!