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

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

looks like a bug to me ! Please raise an issue at Issues · PowerShell/PowerShell · GitHub if possible.