Last active
July 5, 2019 15:52
-
-
Save mattmcnabb/e07c3794a9fd6c8674823663694e2ba5 to your computer and use it in GitHub Desktop.
New up an object with default constructor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# default constructor - has no parameters | |
# method 1 - new and then set properties | |
$Configuration = [Foo.ConfigurationObject]::new() | |
$Configuration.Domain = $DomainName | |
$Configuration.Token = $Token | |
# method 2 - add properties via New-Object | |
$Configuration = New-Object Foo.ConfigurationObject -Property @{ | |
Domain = $DomainName | |
Token = $Token | |
} | |
# method 3 - hashtable instantiation if properties are settable | |
[Foo.ConfigurationObject]@{ | |
Domain = $DomainName | |
Token = $Token | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment