Tutorial by Examples

Adding properties If you'd like to add properties to an existing object, you can use the Add-Member cmdlet. With PSObjects, values are kept in a type of "Note Properties" $object = New-Object -TypeName PSObject -Property @{ Name = $env:username ID = 12 Address...
PowerShell, unlike some other scripting languages, sends objects through the pipeline. What this means is that when you send data from one command to another, it's essential to be able to create, modify, and collect objects. Creating an object is simple. Most objects you create will be custom obj...
Now that you have an object, it might be good to figure out what it is. You can use the Get-Member cmdlet to see what an object is and what it contains: Get-Item c:\windows | Get-Member This yields: TypeName: System.IO.DirectoryInfo Followed by a list of properties and methods the object ha...
Note: examples written for PowerShell 5.1 You can create instances of Generic Classes #Nullable System.DateTime [Nullable[datetime]]$nullableDate = Get-Date -Year 2012 $nullableDate $nullableDate.GetType().FullName $nullableDate = $null $nullableDate #Normal System.DateTime [datetime]$aDa...

Page 1 of 1