npocmaka
npocmaka

Reputation: 57252

How to get full text of get-member cmdlet ( particularly the definition )

E.g. with:

new-object -comobject WScript.Network |get-member -verbose -View all

I have :

   TypeName: System.__ComObject#{24be5a31-edfe-11d2-b933-00104b365c9f}

Name                        MemberType Definition
----                        ---------- ----------
AddPrinterConnection        Method     void AddPrinterConnection (string, st...
AddWindowsPrinterConnection Method     void AddWindowsPrinterConnection (str...
CreateObjRef                Method     System.Runtime.Remoting.ObjRef Create...
EnumNetworkDrives           Method     IWshCollection EnumNetworkDrives ()
EnumPrinterConnections      Method     IWshCollection EnumPrinterConnections ()
Equals                      Method     bool Equals(System.Object obj)
GetHashCode                 Method     int GetHashCode()
GetLifetimeService          Method     System.Object GetLifetimeService()
GetType                     Method     type GetType()
InitializeLifetimeService   Method     System.Object InitializeLifetimeServi...
MapNetworkDrive             Method     void MapNetworkDrive (string, string,...
RemoveNetworkDrive          Method     void RemoveNetworkDrive (string, Vari...
RemovePrinterConnection     Method     void RemovePrinterConnection (string,...
SetDefaultPrinter           Method     void SetDefaultPrinter (string)
ToString                    Method     string ToString()
ComputerName                Property   string ComputerName () {get}
Organization                Property   string Organization () {get}
Site                        Property   string Site () {get}
UserDomain                  Property   string UserDomain () {get}
UserName                    Property   string UserName () {get}
UserProfile                 Property   string UserProfile () {get}

And the DEFINTION text is not the complete one.When I increase the console size I can the full definition of the definition. But I consider this rather as a workaround (this is needed also when I output to a file).How I can get the full text without changing the console size?Is it possible?

Upvotes: 1

Views: 1406

Answers (1)

Nacht
Nacht

Reputation: 3494

if you put your results into a variable, you can index into them like an array:

$x = new-object -comobject WScript.Network |get-member -verbose -View all
$x[0]

which gives

   TypeName: System.__ComObject#{24be5a31-edfe-11d2-b933-00104b365c9f}

Name                 MemberType Definition
----                 ---------- ----------
AddPrinterConnection Method     void AddPrinterConnection (string, string, Variant, Variant, Variant)

you can then get the individual property on your object like this:

PS> $x[0].definition
void AddPrinterConnection (string, string, Variant, Variant, Variant)

another way to get even more method information is by entering the method name on an object and leaving off the spaces:

PS> (new-object -comobject WScript.Network).addprinterconnection

MemberType          : Method
OverloadDefinitions : {void AddPrinterConnection (string, string, Variant, Variant, Variant)}
TypeNameOfValue     : System.Management.Automation.PSMethod
Value               : void AddPrinterConnection (string, string, Variant, Variant, Variant)
Name                : AddPrinterConnection
IsInstance          : True

just get used to the idea that you're dealing with .net objects, and can do a lot of normal object-oriented stuff with them :)

Upvotes: 1

Related Questions