Skip to content

Instantly share code, notes, and snippets.

@mattmcnabb
Last active July 5, 2019 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattmcnabb/e07c3794a9fd6c8674823663694e2ba5 to your computer and use it in GitHub Desktop.
Save mattmcnabb/e07c3794a9fd6c8674823663694e2ba5 to your computer and use it in GitHub Desktop.
New up an object with default constructor
# 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