How can I copy all the properties of an object ( in the below example $S=TypeName: System.ServiceProcess.ServiceController) to a PSCustom object by keeping some more additional properties of its properties. The below is the example..
Sean's point is correct – you don't need to copy the object. PowerShell lets you add properties (and other members) directly to any object. So you should just add them to the ServiceController. PowerShell's extensible type system (ETS) already adds numerous members to the base .NET object.
If for some reason you really do want to create a new object with all the same properties, piping the original object to [b]Select-Object -Property *[/b] will do the trick. You'll wind up with a PSObject containing a bunch of NoteProperties, instead of whatever type the original object was.