New-Object only for .NET Framework or for .net core too ?


Maybe a silly queston, but when I read the documentation on Microsoft docs on the Cmdlet New-Object it specifically mentions it gets something from .NET Framework or Com (nothing about .NET Core)

But maybe now I’m confused, because in PowerShell 7 we use .NET Core? So I assume if I get a system.serviceprocess.servicecontroller instance with new-object I get it from .NET core ? not .NET Framework on a windows machine with PowerShell 7? And on Windows Powershell 5.1 if i get a system.serviceprocess.servicecontroller instance i would get it from .NET Framework? Or am I confused about its operation?




If we want to create a new object of a type, that type has to be loaded first in to the session. By default Powershell loads some .net types and AFAIK, Windows PowerShell loads .Net f/w and Powershell core takes from .Net core.

execute below from both Windows PowerShell and PowerShell core to see from where these are getting loaded.

add-type -AssemblyName microsoft.visualbasic