4

I would like to write some functions that take a single parameter which could vary the type without having to use a whole new function.

For instance for SQL, I would like to either accept sql command text string or a file. or for active directory either the path or the adsi object would be taken

unlock-aduser [adsi]"LDAP://dn=..." or unlock-aduser [string]"LDAP://dn=..."

would work just as well.

James
  • 1,300
  • 11
  • 11
  • For the record, I'd say this is not polymorphism but function overloading. – J.N. Mar 01 '11 at 14:48
  • @J.N function overloading comes under polymorphism... – Shekhar_Pro Mar 01 '11 at 14:50
  • 1
    Not by everybody's definition. http://stackoverflow.com/questions/154577/polymorphism-vs-overriding-vs-overloading/154675#154675. I think not because when you use overloading the behavior is the same, but the inputs are different, while when you use polymorphism you tend to have the same inputs but a different behavior. – J.N. Mar 01 '11 at 14:56

2 Answers2

5

Simply No its not.

However you should take a look here for parametersets

Shekhar_Pro
  • 17,608
  • 8
  • 51
  • 78
1

The Powershell classes in V5 are poloymorphic

http://alexiscoles.blogspot.co.uk/2015/10/polymorphism-powershell-v5-classes.html

Alexis Coles
  • 1,097
  • 12
  • 18