[pscustomobject]@{ Name = 'bob'; Id = 20 }
# can be
[Employee]@{ Name = 'bob'; Id = 20 }
# Create class that we can populate
class Employee {
[ValidateNotNullOrEmpty()]
[string]$Name
[ValidateRange(0,40)]
[int]$Id
}
[Employee]@{ Name = 'bob'; Id = 20 }
[Employee]@{ Name = 'Jen'; Id = 33 }
# OR add object to a list
$list = [system.collections.generic.List[object]]::new()
class Person {
$name
$location
$age
}
$Person = [Person]@{
name = "Noah"
location = "here"
age = "old enough"
}
$list.add($person)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter