I tried to use GetType() to print all type information, but seems much information is missing? I have such input in PS 4.0.(See below)
I tried to use "GetType().GetMethods()" to list all methods. But I did not see
"GetMethods"
itself in the result list. I also used "GetProperties()" to list all properties, but seems there are much more properties like
IsCOMObject
not listed in the result. If I use Visual Studio+C# programming, I could see much more properties listed. Why powershell is missing them?
See my output below:
PS C:\Users\engineer> $PSVersionTable
Name Value
---- -----
PSVersion 4.0
WSManStackVersion 3.0
SerializationVersion https://urldefense.proofpoint.com/v2/url?u=http-3A__1.1.0.1&d=BQIGaQ&c=uGuXJ43KPkPWEl2imVFDmZQlhQUET7pVRA2PDIOxgqw&r=mCXkWZTsMJTTBmlJTS1MIA&m=Ygifer7R65h35BWXXpiU4do9wt2Uao4rSLEgO9vuPHk&s=vwVGdMLhksoC-RbOJWgJ4jNhk1F5c7TrApW_pekpb9M&e=
CLRVersion 4.0.30319.18444
BuildVersion 6.3.9600.16406
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion 2.2
PS C:\Users\engineer> $a=${}
PS C:\Users\engineer> $a.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Hashtable System.Object
PS C:\Users\engineer> $a.GetType().GetMethods().Name|Sort
Add
Clear
Clone
Contains
ContainsKey
ContainsValue
CopyTo
Equals
get_Count
get_IsFixedSize
get_IsReadOnly
get_IsSynchronized
get_Item
get_Keys
get_SyncRoot
get_Values
GetEnumerator
GetHashCode
GetObjectData
GetType
OnDeserialization
Remove
set_Item
Synchronized
ToString
PS C:\Users\engineer> $a.GetType().GetProperties().Name|Sort
Count
IsFixedSize
IsReadOnly
IsSynchronized
Item
Keys
SyncRoot
Values
PS C:\Users\engineer> $a.GetType().IsCOMObject
False
PS C:\Users\engineer>
$a is a HashTable, and your expression is getting all of the methods of the HashTable class. GetMethods is not appearing in the list because it is not a method of class HashTable, it's a method of class Type. IsCOMObject is not appearing in the list because again, it's not a property on class HashTable; it's a property on class Type.
If you want to see all of the things you can do with a Type object, do something like (C#):