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

Welcome Forums General PowerShell Q&A New-Object only for .NET Framework or for .net core too ?

Viewing 1 reply thread
  • Author
    • #270367
      Topics: 3
      Replies: 5
      Points: 37
      Rank: Member


      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?




      • This topic was modified 3 weeks ago by kvprasoon. Reason: Correct title
    • #270385
      Senior Moderator
      Topics: 9
      Replies: 1420
      Points: 5,280
      Helping Hand
      Rank: Community MVP

      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.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.