This repository was archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathFind-PSResource.ps1
More file actions
182 lines (153 loc) · 8.01 KB
/
Copy pathFind-PSResource.ps1
File metadata and controls
182 lines (153 loc) · 8.01 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Replaces: Find-Command, Find-DscResource, Find-Module, Find-RoleCapability, Find-Script
# Parameter Sets: ResourceParameterSet, PackageParameterSet, ScriptParameterSet
# Find-Command returns an object with properties: Name, Version, ModuleName, Repository
# Find-DSCResource returns an object with properties: Name, Version, ModuleName, Repository
# Find-RoleCapability returns an object with properties: Name, Version, ModuleName, Repository
# Find-Module returns an object with properties: Version, Name, Repository, Description
# Find-Script returns an object with properties: Version, Name, Repository, Description
function Find-PSResource {
[OutputType([PSCustomObject[]])]
[Cmdletbinding(SupportsShouldProcess = $true)]
Param
(
# Specifies the name of the resource to be searched for.
# Resources that use this param: Command, DSCResource, RoleCapability, Package, Script.
[Parameter(ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
Position = 0)]
[ValidateNotNullOrEmpty()]
[string[]]
$Name,
# Specifies the type of the resource being searched.
# Resources that use this param: Command, DSCResource, RoleCapability, Package, Script.
[Parameter(ValueFromPipelineByPropertyName = $true)]
[ValidateSet('Module', 'Script', 'DscResource', 'RoleCapability', 'Command')]
[string[]]
$Type,
# Specifies the module name that contains the resource.
# Resources that use this param: Command, DSCResource, RoleCapability.
[Parameter(ParameterSetName = "ResourceParameterSet")]
[ValidateNotNullOrEmpty()]
[string]
$ModuleName,
# Specifies the minimum version of the resource to include in results (cannot use this parameter with the RequiredVersion or AllVersions parameters).
# Resources that use this param: Command, DSCResource, RoleCapability, Package, Script.
[Parameter(ValueFromPipelineByPropertyName = $true)]
[ValidateNotNull()]
[string]
$MinimumVersion,
# Specifies the maximum version of the resource to include in results (cannot use this parameter with the RequiredVersion or AllVersions parameters).
# Resources that use this param: Command, DSCResource, RoleCapability, Package, Script.
[Parameter(ValueFromPipelineByPropertyName = $true)]
[ValidateNotNull()]
[string]
$MaximumVersion,
# Specifies the required version of the resource to include in results (cannot use this parameter with the MinimumVersion, MaximumVersion, or AllVersions parameters).
# Resources that use this param: Command, DSCResource, RoleCapability, Package, Script.
[Parameter(ValueFromPipelineByPropertyName = $true)]
[ValidateNotNull()]
[string]
$RequiredVersion,
# Displays each of a resource's available versions (cannot use this parameter with the MinimumVersion, MaximumVersion, or RequiredVersion parameters).
# Resources that use this param: Command, DSCResource, RoleCapability, Package, Script.
[Parameter()]
[switch]
$AllVersions,
# Includes resources marked as a prerelease.
# Resources that use this param: Command, DSCResource, RoleCapability, Package, Script.
[Parameter()]
[switch]
$Prerelease,
# Specifies tags that categorize modules in a repository.
# Resources that use this param: Command, DSCResource, RoleCapability, Package, Script.
[Parameter()]
[ValidateNotNull()]
[string[]]
$Tag,
# Finds resources based on ModuleName, Description, and Tag properties.
# Resources that use this param: Command, DSCResource, RoleCapability, Package, Script.
[Parameter()]
[ValidateNotNull()]
[string]
$Filter,
# Specifies a proxy server for the request, rather than a direct connection to the internet resource.
# Resources that use this param: Command, DSCResource, RoleCapability, Package, Script.
[Parameter(ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[Uri]
$Proxy,
# Specifies a user account that has permission to use the proxy server that is specified by the Proxy parameter.
# Resources that use this param: Command, DSCResource, RoleCapability, Package, Script.
[Parameter(ValueFromPipelineByPropertyName = $true)]
[PSCredential]
$ProxyCredential,
# Specifies the repository to search within (default is all repositories).
# Resources that use this param: Command, DSCResource, RoleCapability, Package, Script.
[Parameter()]
[ValidateNotNullOrEmpty()]
[string[]]
$Repository,
# Specifies a user account that has rights to find a resource from a specific repository.
# Resources that use this param: Package, Script.
[Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = "PackageParameterSet")]
[Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = "ScriptParameterSet")]
[PSCredential]
$Credential,
# Specifies to include all modules that are dependent upon the module specified in the Name parameter.
# Resources that use this param: Package, Script.
[Parameter(ParameterSetName = "PackageParameterSet")]
[Parameter(ParameterSetName = "ScriptParameterSet")]
[switch]
$IncludeDependencies,
# Returns only those modules that include specific kinds of PowerShell functionality. For example, you might only want to find modules that include DSCResource.
# The acceptable values for this parameter are as follows:
# Module: DscResource, Cmdlet, Function, RoleCapability;
# Scripts: Function, Workflow;
# Resources that use this param: Package, Script.
[Parameter(ParameterSetName = "PackageParameterSet")]
[Parameter(ParameterSetName = "ScriptParameterSet")]
[ValidateNotNull()]
[ValidateSet('DscResource', 'Cmdlet', 'Function', 'RoleCapability', 'Workflow')]
[string[]]
$Includes,
# Specifies the name of the DSC resources contained within a module (per PowerShell conventions, performs an OR search when you provide multiple arguments).
# Resources that use this param: Package.
[Parameter(ParameterSetName = "PackageParameterSet")]
[ValidateNotNull()]
[string[]]
$DscResource,
# Specifies the name of the role capabilities contained within a module (per PowerShell conventions, performs an OR search when you provide multiple arguments).
# Resources that use this param: Package.
[Parameter(ParameterSetName = "PackageParameterSet")]
[ValidateNotNull()]
[string[]]
$RoleCapability,
# Specifies commands to find in modules (command can be a function or workflow).
# Resources that use this param: Package, Script.
[Parameter(ParameterSetName = "PackageParameterSet")]
[Parameter(ParameterSetName = "ScriptParameterSet")]
[ValidateNotNull()]
[string[]]
$Command
)
begin {
# For each repository, if local cache does not exist then Update-PSResourceCache
}
process {
# Returning the array of resources
$foundResources
foreach ($n in $name) {
if ($pscmdlet.ShouldProcess($n)) {
$PSResource = [PSCustomObject] @{
Name = $Name
Version = "placeholder-for-module-version"
Type = $Type
Description = "placeholder-for-description"
}
$foundResources += $PSResource
}
}
return $foundResources
}
end { }
}