Analyze an existing object

List data types of an object

$object | Get-Member | select TypeName -Unique
  • abbriviate $object | gm | select Typename -Unique

List members of an object

$object | Get-Member

Numbers

Integers

  • Convert automatically to larger types
  • [Int32], [Int] 32-bit signed integer
  • [Int64], [Long] 64-bit signed integer
[Int] $smallNumber = 2147483647
[Long] $highNumber = 9223372036854775807

Decimal numbers

  • [Single], [Float] Single-precision 32-bit floating point number
  • [Double] Double-precision 64-bit floating point number
[Float] $lowPrecision = 15.95459
[Double] $highPrecision = 15.954589770191

Boolean

  • [Boolean] Logical value
[Boolean] $enabled = $True 
[Bool] $disabled = $False

Text

  • [Char] Single Unicode 16-bit character
  • [String] Fixed-length string of Unicode characters
    Char (A Unicode 16-bit character)
[Char] $letter = "a"
[String] $evaluatedString = "Hello $env:Username"
[String] $unevaluatedString = 'Raw <>|$&%\Text'
[String] $combinedString1 = ("Found " + $_.Name + "!")
[String] $combinedString2 = ("Found $($_.Name)!")
[String] $combinedString3 = [String]@(
    "Found ",
    $_.Name,
    "!"
)
[String] $multilineString = @”  
First-line  
Second line  
Third line  
“@

Date and time

Time and Dates - Handle temporal data like day of week, clock time, or first day of month > Overview

Collect multiple items in containers like arrays or dictionaries

Containers - Collect multiple items in containers like arrays or dictionaries > Overview


Sources:

Related:
How types make hard problems easy

Tags: