PoshCode Logo PowerShell Code Repository

Get-Constructor (modification of post by view diff)
View followups from Joel Bennett and Joel Bennett | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1368"></script>download | new post

Enumerates the constructors of a type with the parameters that they take, so you can figure out what your options are when calling New-Object.

  1. function Get-Constructor {
  2. PARAM( [Type]$type )
  3. $type.GetConstructors() |
  4.         Format-Table @{
  5.                 l="$($type.Name) Constructors"
  6.                 e={ ($_.GetParameters() | % { $_.ToString() }) -Join ", " }
  7.         }
  8. }
  9.  
  10. Set-Alias gctor Get-Constructor

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me