Getting the Object Type in PowerShell
First post of the year and in a while and I would like to talk about the types of the objects in PowerShell. Much like C#, each object has a type in PowerShell. This type is proven to be very helpful when developing functions and cmdlets since it provides information about the object we are dealing with. For example you may have a variable that holds the value "1" but it can be of type string, integer, double and others. The way to differentiate is to examine the type of the variable. There are may ways to get the type of a PowerShell object but first, let's get the newest event in the application log to use as example: PS C:\> $obj = Get-EventLog -LogName Application -Newest 1 PS C:\> $obj Index Time EntryType Source InstanceID Message ----- ---- --------- ------ ---------- ------- 3882 Jan 07 20:39 Information ESENT 916 svchost (3356,...