PowerShell summer tips 05
This is number 5 in my series of PowerShell summer tips.
As I mentioned before, PowerShell is Object oriented.
And If you want to be in command you want to know the type of an object.
This is very easy.
# Get the type of some text
$someText = "Hello World"
# or without a variable
# Check the type from Get-Item on the windows folder
# Check the type from Get-ChildItem on the windows folder
# Check the type from Get-Item on the registry
(Get-Item -Path "HKLM:\SOFTWARE\").GetType()
# Check the type on Get-Date
This is very handy when you need to do error handling or do deep dives into stuff.
# One plus two equals 3 or?
$one = "1"
$two = "2"
$one + $two
I will digg deeper into types and how PowerShell handels them later on.
Another reason to know the type of an object is if you need to get more information.