I’m playing around with the latest WMF 5 build doing fun stuff with classes, and I ran across a situation where I’d like to use optional parameters instead of creating a bunch of overloads. I can’t find much about this topic either online or in the about_classes help file. Also I’m not a real developer so I could be thinking about this all wrong. This C# reference mentions the use of optional arguments to a method, which I think is what I’d like to do with powershell:
https://msdn.microsoft.com/en-us/library/dd264739.aspx
Basically I have a class IB_DNSARecord with a method Get:
`
[IB_DNSARecord]::Get($gridmaster,$credential,“wapitest.domain.com”)
`
This will get the DNS A record that matches that name exactly. Another option would be to do a search that matches any record that is similar rather than exact, and ideally I’d like to do it like this:
`
[IB_DNSARecord]::Get($gridmaster,$credential,“wapitest.domain.com”,“False”)
`
where the third parameter determines whether or not to do a strict search (True would be the default if not specified). Currently this blows up on me, so it seems like I’d have to do an overload for it and re-use a bunch of code.
Any ideas?