Skip to content

Latest commit

 

History

History
73 lines (54 loc) · 1.75 KB

7-Types-in-Powershell.md

File metadata and controls

73 lines (54 loc) · 1.75 KB

7. Types in Powershell

  • Dynamic Types - Not strictly typed
PS C:\Users\Windows-32> $value = "string" + 1
PS C:\Users\Windows-32> $value.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String                                   System.Object


PS C:\Users\Windows-32>
  • Basis of PowerShell types is .Net

  • Type Adaption – Provides access to alternate object systems like WMI, COM, ADSI etc.

  • Single quoted vs Double qouted

PS C:\Users\Windows-32> $str = "This is a string"
PS C:\Users\Windows-32> $str.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String                                   System.Object


PS C:\Users\Windows-32>
PS C:\Users\Windows-32> $str = 'This is a string'
PS C:\Users\Windows-32> $str.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String                                   System.Object


PS C:\Users\Windows-32>
PS C:\Users\Windows-32> "Another String $str"
Another String This is a string
PS C:\Users\Windows-32>
PS C:\Users\Windows-32> 'Another String $str'
Another String $str
PS C:\Users\Windows-32>
  • Here Strings - Multiline
PS C:\Users\Windows-32> @"
>> hi
>> this
>> is
>> a
>> line
>> "@
>>
hi
this
is
a
line
PS C:\Users\Windows-32>