Could not load file or assembly 'Microsoft.IdentityServer

Had something odd happen on my Test instance. I upgraded PowerShell to 7.4.6 from 7.4.5. After that I could not get any dashboard to start. All error with the following:
[12/13/2024 11:10:10 AM] [Error] [App-CertServicesStatus] Failed to get dashboard. Could not load file or assembly ‘Microsoft.IdentityServer, Culture=neutral, PublicKeyToken=null’. The system cannot find the file specified. System.Management.Automation.CmdletInvocationException

I am using OpenID Connect integration with Entra ID on the test instance (WinServer2019). My OpenID login to the admin console of PU works successfully. But I get the same error whether I have authentication turned on or not on a dashboard itself. This affected all my dashboards in this instance.
I even went so far as to completely uninstall PU, installed msi from scratch, reconfigured all my OIDC setup, modules and created a basic default dashboard. Still getting the same error. There are more lines in the debug log which I will post below.
My locally installed Dev instance works fine with POSH 7.4.6 (Win11) but it doesn’t use OIDC. Only local login.
Any ideas on what I broke? and how to fix it?

Powershell 7.4.6
Product: PowerShell Universal Version: 5.1.0

Below is the whole log entry when attempting to start the dashboard:
[12/13/2024 11:10:10 AM] [Information] [App-CertServicesStatus] Dashboard configuration complete.
[12/13/2024 11:10:10 AM] [Error] [App-CertServicesStatus] Inner Exception: System.IO.FileNotFoundException
[12/13/2024 11:10:10 AM] [Error] [App-CertServicesStatus] at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.Runspaces.Pipeline.Invoke()
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection1 input, PSDataCollection1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection1 input, PSDataCollection1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TOutput](IEnumerable input, PSDataCollection1 output, PSInvocationSettings settings) at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, IList1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.InvokeT
at System.Management.Automation.Runspaces.InitialSessionState.ProcessOneModule(Runspace initializedRunspace, String name, PSModuleInfo moduleInfoToLoad, String path, HashSet1 publicCommands, List1 processedModules)
at System.Management.Automation.Runspaces.InitialSessionState.ProcessModulesToImport(Runspace initializedRunspace, IEnumerable moduleList, String path, HashSet1 publicCommands, HashSet1 unresolvedCmdsToExpose)
at System.Management.Automation.Runspaces.InitialSessionState.BindRunspace(Runspace initializedRunspace, PSTraceSource runspaceInitTracer)
at System.Management.Automation.Runspaces.LocalRunspace.DoOpenHelper()
at System.Management.Automation.Runspaces.LocalRunspace.OpenHelper(Boolean syncCall)
at System.Management.Automation.Runspaces.RunspaceBase.CoreOpen(Boolean syncCall)
at System.Management.Automation.Runspaces.RunspaceBase.Open()
at UniversalDashboard.Services.UDRunspaceFactory.CreateRunspace() in C:\actions-runner_work\universal\universal\src\UniversalDashboard\Services\UDRunspaceFactory.cs:line 229
at UniversalDashboard.Services.UDRunspaceFactory.Create() in C:\actions-runner_work\universal\universal\src\UniversalDashboard\Services\UDRunspaceFactory.cs:line 360
at Microsoft.Extensions.ObjectPool.DefaultObjectPool`1.Get()
at UniversalDashboard.Services.UDRunspaceFactory.GetRunspaceReference() in C:\actions-runner_work\universal\universal\src\UniversalDashboard\Services\UDRunspaceFactory.cs:line 80
at UniversalDashboard.Services.UDRunspaceFactory.GetRunspaceAsync() in C:\actions-runner_work\universal\universal\src\UniversalDashboard\Services\UDRunspaceFactory.cs:line 59
at UniversalAutomation.Host.UniversalDashboardService.StartDashboard() in C:\actions-runner_work\universal\universal\src\Host\DashboardService.cs:line 117
[12/13/2024 11:10:10 AM] [Error] [App-CertServicesStatus] Failed to get dashboard. Could not load file or assembly ‘Microsoft.IdentityServer, Culture=neutral, PublicKeyToken=null’. The system cannot find the file specified. System.Management.Automation.CmdletInvocationException
[12/13/2024 11:10:07 AM] [Information] [App-CertServicesStatus] Creating runspace factory.
[12/13/2024 11:10:07 AM] [Information] [App-CertServicesStatus] Adding built in variables.
[12/13/2024 11:10:07 AM] [Information] [App-CertServicesStatus] *
[12/13/2024 11:10:07 AM] [Information] [App-CertServicesStatus] Generating initial session state.
[12/13/2024 11:10:07 AM] [Information] [App-CertServicesStatus] Creating services.
[12/13/2024 11:10:07 AM] [Information] [App-CertServicesStatus] Dashboard information received. Starting dashboard.
[12/13/2024 11:10:07 AM] [Information] [App-CertServicesStatus] Waiting for dashboard information…

It seems like PSU might be using an older version of some assembly that Microsoft.IdentityServer relies on. It doesn’t look like PowerShell 7.4.6 ships with this assembly directly, but they have updated some assembly in 7.4.6 from 7.4.5.

Here’s the commit: Bump to .NET 8.0.403 and update dependencies by adityapatwardhan · Pull Request #24405 · PowerShell/PowerShell · GitHub

PSU already uses a newer .NET SDK version than PS so that isn’t the issue, but I do wonder about the other assembly references they have changed.

What type of environment are you using for your dashboards? What modules are you using in them?

I am using the Powershell 7 environments for those dashboards. Some custom modules and some public ones. But everything worked fine on my local instance. To provide additional info, I just now completely uninstalled both PU and Powershell 7. Deleted all PU folders. Restarted the server. Then did a fresh vanilla install of PU 5.1.0. Stopped the PU service. Copied my saved appsettings.json, copied the default repository/database over to the E drive (which is where the custom appsettings.json sets it to). Then restarted PU service. Everything started as expected. My https is working. Recreated my OpenID connection and that login works as expected. Created a vanilla dashboard and it works. Installed the modules I needed for my dashboards then copied over one of the previously affected dashboards and configured it as before. It now works correctly. No errors.
NOTE: I did NOT reinstall POSH 7 on the server, currently the only POSH 7 that is available is the one in PU.
To validate that everything still works, I copied over another dashboard that was affected, configured it and it works without error.
So, my suspicion is the install of POSH 7.4.6 to the server is what broke it. But the only way for me to confirm that is to reinstall POSH 7 now that I have PU working and see if it breaks again. I might do that just to confirm whether that is the issue or i just did something stupid.

OK, just reinstalled powershell 7.4.6 and rebooted the server. All the dashboards came back up without error. so, it must have been something I did. I am not sure what. The only other thing I was working on was trying to resolve a name conflict between the modules Apps.PowerShell.Tools and Universal.Utilities.Apps. I couldnt get Show-UDObject to load when I was editing using VSCode and I thought that maybe the two modules were conflicting. So, I removed the Universal.Utilities.Apps module in favor of the Apps.PowerShell.Tools module since this is the ‘newer’ one. It was after this that i started having the issue. Not convinced that is what did it. Right now, I only have Apps.PowerShell.Tools installed. Its resolved. Probably my mistake.

1 Like