Why is Get-Member different in Get-Service for PS 7.0 and Windows PS 5.1

Welcome Forums General PowerShell Q&A Why is Get-Member different in Get-Service for PS 7.0 and Windows PS 5.1

Viewing 1 reply thread
  • Author
    Posts
    • #216180
      Participant
      Topics: 1
      Replies: 0
      Points: 11
      Rank: Member

      Hi people,

      So if I do $MyService = Get-Service -Name “ALG”

      And then I do $MyService | Get-Member in Windows PowerShell 5.1 I get the type I’m expecting which is System.ServiceProcess.ServiceController

      If I do $MyService = Get-Service -Name “ALG”

      And then I do $MyService | Get-Member in  PowerShell 7.0  I get this

      System.Service.ServiceController#StartupType  which doesn’t make sence to me.

       

      However when I create a service controller object n both Windows PowerShell 5.1 and PowerShell 7.0 as such :

      $MyService = New-Object -TypeName System.ServiceProcess.ServiceController(“ALG”)

      Then I Do $MyService | Get-Member  in both PowerShell 7.0 as Windows PowerShell 5.1

      I get the correct expected type System.ServiceProcess.ServiceController

      Could anyone explain me why this ?

      thank you a lot

      Henk

    • #216207
      Senior Moderator
      Topics: 8
      Replies: 1215
      Points: 4,335
      Helping Hand
      Rank: Community Hero

      looks like a bug to me ! Please raise an issue at https://github.com/PowerShell/PowerShell/issues if possible.

      • This reply was modified 1 month, 3 weeks ago by kvprasoon.
Viewing 1 reply thread
  • You must be logged in to reply to this topic.