Powershell ISE import-module

I am unable to import-module with PowerShell ISE, but it works fine from the normal CLI. Is this possible?

Import-Module : Could not load file or assembly ‘Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’ or one of its dependencies. The system cannot find the file specified.

Thanks!

EDIT: This error was on a 2012R2 server, I tested again on Windows 10 ISE and worked fine. Looks like I need to try a newer server OS.

EDIT 2: I installed the msi on a brand new 2016 server and get the same error importing with CLI or ISE. :upside_down_face:

This might have to do with other modules that are being imported into the ISE.

You can see where the other version of NewtonSoft is being loaded from by checking the app domain.

[AppDomain]::CurrentDomain.GetAssemblies()

I didn’t see any reference to NewtonSoft checking the appDomain.

I was able to get this working by adding the import-module commands to my $profile as the first 2 lines. This worked on both servers that had the issue.

Hey try running this before you import the Universal dashboard. I have had this issue before, and the bellow fixed it.

[System.Reflection.Assembly]::LoadFrom(“C:\Program Files (x86)\Universal\Cmdlets\NewtonSoft.Json.dll”)

1 Like