Endpoint working locally but not on IIS

Hello,

I have an endpoint that works locally but not on IIS.
I use the same identification file for the Connect-MsolService command and the Active Directory commands for my other endpoints.
Locally everything works but on IIS there are only Active Directory commands that work.

Here is the code for my endpoint :

New-UDEndpoint -Endpoint {
try
{
    function Get-MsolLicenses
    {
        [CmdletBinding()]
        [OutputType([array])]
        param ()
        
        $MsolLicenses = Get-MsolAccountSku
        $MsolLicenses |
        Select-Object @{
            Name	   = "LicenseName";
            Expression = {
                if ($_.AccountSkuId -eq "company:SPE_E3")
                {
                    "Microsoft 365 E3"
                }
                elseif ($_.AccountSkuId -eq "company:SPE_E5")
                {
                    "Microsoft 365 E5"
                }
                elseif ($_.AccountSkuId -eq "company:EXCHANGESTANDARD")
                {
                    "Exchange Online ‎(Plan 1)"
                }
                elseif ($_.AccountSkuId -eq "company:STANDARDPACK")
                {
                    "Office 365 Entreprise E1"
                }
                elseif ($_.AccountSkuId -eq "company:EMS")
                {
                    "Enterprise Mobility + Security E3"
                }
                elseif ($_.AccountSkuId -eq "company:EMSPREMIUM")
                {
                    "Enterprise Mobility + Security E5"
                }
                elseif ($_.AccountSkuId -eq "company:DESKLESSPACK")
                {
                    "Office 365 F1"
                }
                elseif ($_.AccountSkuId -eq "company:PROJECTPROFESSIONAL")
                {
                    "Microsoft Project"
                }
                elseif ($_.AccountSkuId -eq "company:VISIOCLIENT")
                {
                    "Microsoft Visio"
                }
                else
                {
                    $_.AccountSkuId
                }
            }
        },
                    @{
            Name	   = "AvailableUnits";
            Expression = { $_.ActiveUnits - $_.ConsumedUnits }
        },
        "ConsumedUnits", 
        "ActiveUnits" |
        Sort-Object "LicenseName"
    }

    $RemoteCredential = $Cache:ConnectionInfo.Credential
    Connect-MsolService -Credential $RemoteCredential -ErrorAction Stop
    $Cache:MsolLicenses = Get-MsolLicenses
}
catch
{
    $Error[0]
}
finally
{
    
}
} -Schedule (New-UDEndpointSchedule -Every 600 -Second)

Any ideas ?

Hi @bryce426
Do you have any logging enabled?

Enable-UDLogging -level Debug

Would be nice to know what is failing.

@bryce426

I don’t quite have it working, but here are a few observations that might lead you somewhere.

  1. Make sure you manually load your MSOnline module. (Import-Module…)
  2. I’m running my App Pool with a service account.
  3. Is the ID account you’re using configured for MFA? I had to create a special account in AzureAD that doesn’t use MFA to get other scripts to work in Powershell.

I’m now getting this error when trying to run Connect-MSOLService from UD.

Could not load type ‘System.IdentityModel.Tokens.JwtSecurityToken’ from assembly ‘System.IdentityModel.Tokens.Jwt, Version=5.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’.

I’ll try to play with it more later. Time for the morning meetings to start.

In case you havent seen it your problem is also mentioned here Could not load type when using connect-msolservice in an endpoint

1 Like

Ah yeah, forgot about that. I do remember reading that one now. Its probably why I hadn’t added this to my dashboard in the first place… @bryce426 hadn’t mentioned the specific error, so maybe that will cover it.

Thanks!

1 Like

Thank you for all your quick and detailed answers :wink:

@eefisherv

  • manually load MSOnline module : YES
  • running App Pool with a service account : I just configured my user to have ‘logon as a service’ permissions but the problem remains the same
  • Is the ID account you’re using configured for MFA? : NO

@BoSen29 I tried to activate the logs but I quickly find myself with a 50MB file containing the same line: “AutoReloader OnFileChanged - C: \ inetpub \ wwwroot \ log.txt” and (unless I am mistaken) nothing about the endpoint…
I’m not a developer so I’m not used to debugging. I entered the command “Enable-UDLogging -Level Debug -FilePath .\log.txt” in dashboard.ps1.
I’ll try again tomorrow.

@augustin.ziegler It seems to correspond to my problem but if I understand correctly there is no solution?

@bryce426 sorry but only knew that there is already an related issue … it seams that there is no solution … But maybe it will help to ask for an update in that forum thread …

Mapping related GitHub issue - https://github.com/ironmansoftware/universal-dashboard/issues/1356

@BoSen29 Here is the log file : https://www2.wesend.com/redirect?p=pxqjw94551

Edit: my endpoint is in the azure.ps1 file

1 Like