What are the default assembly loaded in PowerShell 7

Viewed 53

I can't find anywhere about the default assembly loaded in the PowerShell 7.
As I need to make use of some .NET Core libraries directly in the PowerShell 7 Script, so it'll be helpful if I can tell which assemblies are already loaded.

1 Answers

You can enumerate the assemblies currently loaded by calling AppDomain.GetAssemblies():

[System.AppDomain]::CurrentDomain.GetAssemblies() |ForEach-Object GetName |Sort-Object Name

Run in a fresh instance of pwsh to see what's available out of the gate.

As mklement0 notes in the comments, you'll want to launch pwsh with the -NoProfile command line switch to avoid listing explicit dependencies of modules or assemblies loaded in your profile script (here using an encoded version of the one-liner above, for portability):

pwsh.exe -NoProfile -EncodedCommand WwBTAHkAcwB0AGUAbQAuAEEAcABwAEQAbwBtAGEAaQBuAF0AOgA6AEMAdQByAHIAZQBuAHQARABvAG0AYQBpAG4ALgBHAGUAdABBAHMAcwBlAG0AYgBsAGkAZQBzACgAKQAgAHwARgBvAHIARQBhAGMAaAAtAE8AYgBqAGUAYwB0ACAARwBlAHQATgBhAG0AZQAgAHwAUwBvAHIAdAAtAE8AYgBqAGUAYwB0ACAATgBhAG0AZQA=
Related