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 pathUpdate-PSResource.ps1
More file actions
90 lines (76 loc) · 3.03 KB
/
Update-PSResource.ps1
File metadata and controls
90 lines (76 loc) · 3.03 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
# Updating resources
function Update-PSResource {
[OutputType([void])]
[cmdletbinding(SupportsShouldProcess = $true)]
Param
(
# Specifies the names of one or more modules to update.
[Parameter(ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
Position = 0)]
[ValidateNotNullOrEmpty()]
[String[]]
$Name,
# Specifies the required version of the resource to include to be updated (cannot use this parameter with the MaximumVersion or UpdateTo parameters).
[Parameter(ValueFromPipelineByPropertyName = $true)]
[ValidateNotNull()]
[string]
$RequiredVersion,
# Specifies the required version of the resource to include to be updated (cannot use this parameter with the RequiredVersion or UpdateTo parameters).
[Parameter(ValueFromPipelineByPropertyName = $true)]
[ValidateNotNull()]
[string]
$MaximumVersion,
# Allows updating to latest path version, minor version, or major version (cannot use this parameter with the MaximumVersion or RequiredVersion parameters).
[Parameter(ValueFromPipelineByPropertyName = $true)]
[ValidateSet("PatchVersion", "MinorVersion", "MajorVersion")]
[string]
$UpdateTo,
# Specifies a user account that has permission to save a resource from a specific repository.
[Parameter(ValueFromPipelineByPropertyName = $true)]
[PSCredential]
$Credential,
# Saves a resource without asking for user confirmation.
[Parameter()]
[ValidateSet("CurrentUser", "AllUsers")]
[string]
$Scope,
# Specifies a proxy server for the request, rather than connecting directly to an internet resource.
[Parameter(ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[Uri]
$Proxy,
# Specifies a user account that has permission to use the proxy server specified by the Proxy parameter.
[Parameter(ValueFromPipelineByPropertyName = $true)]
[PSCredential]
$ProxyCredential,
# Updates a resource without asking for user confirmation.
[Parameter()]
[Switch]
$Force,
# Allows an update to a prerelease version.
[Parameter()]
[Switch]
$Prerelease,
# Automatically accept the license agreement if the resoruce requires it.
[Parameter()]
[switch]
$AcceptLicense,
# Returns the resource as an object to the console.
[Parameter()]
[switch]
$PassThru
)
begin { }
process {
foreach ($n in $Name) {
if ($pscmdlet.ShouldProcess($n)) {
if (Get-InstalledResource $n) {
# Use install logic to update resource
write-verbose -message "Successfully updated $n"
}
}
}
}
end { }
}