Repository: PowerShell/PowerShell
File: src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs (C#)

Code before:

                if (hScManager != IntPtr.Zero)
                {
                    bool succeeded = NativeMethods.CloseServiceHandle(hScManager);
                    if (!succeeded)
                    {
                        Diagnostics.Assert(lastError != 0, "ErrorCode not success");
                    }
                }
            }

            return serviceAsPSObj;
        }
    }
    #endregion GetServiceCommand

    #region ServiceOperationBaseCommand
    /// <summary>
    /// This class implements the base for service commands which actually
    /// act on the service(s).
    /// </summary>
    public abstract class ServiceOperationBaseCommand : MultipleServiceCommandBase
    {
        #region Parameters
        /// <summary>
        /// Gets/sets an array of service names.
        /// </summary>
        /// <remarks>
        /// The ServiceName parameter is declared in subclasses,
        /// since it is optional for GetService and mandatory otherwise.
        /// </remarks>
        [Parameter(Position = 0, ParameterSetName = "Default", Mandatory = true, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true)]
        [Alias("ServiceName")]
        public string[] Name
        {
            get
            {
                return serviceNames;
            }

            set
            {
                serviceNames = value;
                selectionMode = SelectionMode.ServiceName;
            }
        }

        /// <summary>
        /// Service controller objects.
        /// </summary>
        [Parameter(Position = 0, Mandatory = true, ParameterSetName = "InputObject", ValueFromPipeline = true)]

Review comment (suggestion):
Those added ETS properties are displayed in `Get-Member` as `Property` (see below picture), and it's hard to tell if they are from the .NET object. Can we use `NoteProperty` instead so that they are shown as `NoteProperty` like we do for `FileInfo` in `Get-Member` output? 

![image](https://github.com/user-attachments/assets/f7aee2e6-1873-42e0-97d8-9926b42aac2d)

![image](https://github.com/user-attachments/assets/1e3d7fd1-86b7-42bf-9e90-5f5b5b579091)


Code after:
                {
                    bool succeeded = NativeMethods.CloseServiceHandle(hService);
                    Diagnostics.Assert(succeeded, "Failed to close service handle");
                }
            }

            PSObject serviceAsPSObj = PSObject.AsPSObject(service);
            PSNoteProperty noteProperty = new("UserName", startName);
            serviceAsPSObj.Properties.Add(noteProperty, true);
            serviceAsPSObj.TypeNames.Insert(0, "System.Service.ServiceController#UserName");

            noteProperty = new PSNoteProperty("Description", description);
            serviceAsPSObj.Properties.Add(noteProperty, true);
            serviceAsPSObj.TypeNames.Insert(0, "System.Service.ServiceController#Description");

            noteProperty = new PSNoteProperty("DelayedAutoStart", isDelayedAutoStart);
            serviceAsPSObj.Properties.Add(noteProperty, true);
            serviceAsPSObj.TypeNames.Insert(0, "System.Service.ServiceController#DelayedAutoStart");

            noteProperty = new PSNoteProperty("BinaryPathName", binPath);
            serviceAsPSObj.Properties.Add(noteProperty, true);
            serviceAsPSObj.TypeNames.Insert(0, "System.Service.ServiceController#BinaryPathName");

            noteProperty = new PSNoteProperty("StartupType", startupType);
            serviceAsPSObj.Properties.Add(noteProperty, true);
            serviceAsPSObj.TypeNames.Insert(0, "System.Service.ServiceController#StartupType");

            return serviceAsPSObj;
        }
    }
#nullable disable
    #endregion GetServiceCommand

    #region ServiceOperationBaseCommand
    /// <summary>
    /// This class implements the base for service commands which actually
    /// act on the service(s).
    /// </summary>
    public abstract class ServiceOperationBaseCommand : MultipleServiceCommandBase
    {
        #region Parameters
        /// <summary>
        /// Gets/sets an array of service names.
        /// </summary>
        /// <remarks>
        /// The ServiceName parameter is declared in subclasses,
        /// since it is optional for GetService and mandatory otherwise.
        /// </remarks>
        [Parameter(Position = 0, ParameterSetName = "Default", Mandatory = true, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true)]
        [Alias("ServiceName")]
        public string[] Name