-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-Constructor.ps1
More file actions
104 lines (85 loc) · 3.96 KB
/
Get-Constructor.ps1
File metadata and controls
104 lines (85 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
Function Get-Constructor {
<#
.SYNOPSIS
Displays the available constructor parameters for a given type
.DESCRIPTION
Displays the available constructor parameters for a given type
.PARAMETER Type
The type name to list out available contructors and parameters
.PARAMETER AsObject
Output the results as an object instead of a formatted table
.EXAMPLE
Get-Constructor -Type "adsi"
DirectoryEntry Constructors
---------------------------
System.String path
System.String path, System.String username, System.String password
System.String path, System.String username, System.String password, System.DirectoryServices.AuthenticationTypes aut...
System.Object adsObject
Description
-----------
Displays the output of the adsi contructors as a formatted table
.EXAMPLE
"adsisearcher" | Get-Constructor
DirectorySearcher Constructors
------------------------------
System.DirectoryServices.DirectoryEntry searchRoot
System.DirectoryServices.DirectoryEntry searchRoot, System.String filter
System.DirectoryServices.DirectoryEntry searchRoot, System.String filter, System.String[] propertiesToLoad
System.String filter
System.String filter, System.String[] propertiesToLoad
System.String filter, System.String[] propertiesToLoad, System.DirectoryServices.SearchScope scope
System.DirectoryServices.DirectoryEntry searchRoot, System.String filter, System.String[] propertiesToLoad, System.D...
Description
-----------
Takes input from pipeline and displays the output of the adsi contructors as a formatted table
.EXAMPLE
"adsisearcher" | Get-Constructor -AsObject
Type Parameters
---- ----------
System.DirectoryServices.DirectorySearcher {}
System.DirectoryServices.DirectorySearcher {searchRoot}
System.DirectoryServices.DirectorySearcher {searchRoot, filter}
System.DirectoryServices.DirectorySearcher {searchRoot, filter, propertiesToLoad}
System.DirectoryServices.DirectorySearcher {filter}
System.DirectoryServices.DirectorySearcher {filter, propertiesToLoad}
System.DirectoryServices.DirectorySearcher {filter, propertiesToLoad, scope}
System.DirectoryServices.DirectorySearcher {searchRoot, filter, propertiesToLoad, scope}
Description
-----------
Takes input from pipeline and displays the output of the adsi contructors as an object
.INPUTS
System.Type
.OUTPUTS
System.Constructor
System.String
.NOTES
Author: Boe Prox
Date Created: 28 Jan 2013
Version 1.0
#>
[cmdletbinding()]
Param (
[parameter(ValueFromPipeline=$True)]
[Type]$Type,
[parameter()]
[switch]$AsObject
)
Process {
If ($PSBoundParameters['AsObject']) {
$type.GetConstructors() | ForEach {
$object = New-Object PSobject -Property @{
Type = $_.DeclaringType
Parameters = $_.GetParameters()
}
$object.pstypenames.insert(0,'System.Constructor')
Write-Output $Object
}
} Else {
$Type.GetConstructors() | Select @{
Label="$($type.Name) Constructors"
Expression={($_.GetParameters() | ForEach {$_.ToString()}) -Join ", "}
}
}
}
}