7
7
[ValidateSet (' repository' , ' psresource' , ' repositories' , ' psresources' )]
8
8
[string ]$ResourceType ,
9
9
[Parameter (Mandatory = $true )]
10
- [ValidateSet (' get' , ' set' , ' export ' , ' test ' )]
10
+ [ValidateSet (' get' , ' set' , ' test ' , ' export ' )]
11
11
[string ]$Operation ,
12
12
[Parameter (ValueFromPipeline )]
13
13
$stdinput
@@ -16,28 +16,17 @@ param(
16
16
function Write-Trace {
17
17
param (
18
18
[string ]$message ,
19
- [string ]$level = ' Error'
19
+
20
+ [ValidateSet (' error' , ' warn' , ' info' , ' debug' , ' trace' )]
21
+ [string ]$level = ' trace'
20
22
)
21
23
22
24
$trace = [pscustomobject ]@ {
23
25
$level.ToLower () = $message
24
26
} | ConvertTo-Json - Compress
25
27
26
- if ($level -eq ' Error' ) {
27
- $host.ui.WriteErrorLine ($trace )
28
- }
29
- elseif ($level -eq ' Warning' ) {
30
- $host.ui.WriteWarningLine ($trace )
31
- }
32
- elseif ($level -eq ' Verbose' ) {
33
- $host.ui.WriteVerboseLine ($trace )
34
- }
35
- elseif ($level -eq ' Debug' ) {
36
- $host.ui.WriteDebugLine ($trace )
37
- }
38
- else {
39
- $host.ui.WriteInformation ($trace )
40
- }
28
+ $host.ui.WriteInformation ($trace )
29
+
41
30
}
42
31
43
32
# catch any un-caught exception and write it to the error stream
@@ -194,14 +183,14 @@ function SetPSResources {
194
183
}
195
184
196
185
if ($resourcesToUninstall.Count -gt 0 ) {
197
- Write-Trace - message " Uninstalling resources: $ ( $resourcesToUninstall | ForEach-Object { " $ ( $_.Name ) - $ ( $_.Version ) " }) " - Level Verbose
186
+ Write-Trace - message " Uninstalling resources: $ ( $resourcesToUninstall | ForEach-Object { " $ ( $_.Name ) - $ ( $_.Version ) " }) "
198
187
$resourcesToUninstall | ForEach-Object {
199
188
Uninstall-PSResource - Name $_.Name - Scope $scope - ErrorAction Stop
200
189
}
201
190
}
202
191
203
192
if ($resourcesToInstall.Count -gt 0 ) {
204
- Write-Trace - message " Installing resources: $ ( $resourcesToInstall.Values | ForEach-Object { " $ ( $_.Name ) -- $ ( $_.Version ) " }) " - Level Verbose
193
+ Write-Trace - message " Installing resources: $ ( $resourcesToInstall.Values | ForEach-Object { " $ ( $_.Name ) -- $ ( $_.Version ) " }) "
205
194
$resourcesToInstall.Values | ForEach-Object {
206
195
Install-PSResource - Name $_.Name - Version $_.Version - Scope $scope - Repository $repositoryName - ErrorAction Stop
207
196
}
@@ -363,21 +352,17 @@ function PopulateRepositoryObject {
363
352
)
364
353
365
354
$repository = if (-not $RepositoryInfo ) {
366
- Write-Trace - message " RepositoryInfo is null or empty. Returning _exist = false" - Level Information
355
+ Write-Trace - message " RepositoryInfo is null or empty. Returning _exist = false"
367
356
368
357
$inputJson = $stdinput | ConvertFrom-Json - ErrorAction Stop
369
358
370
359
[pscustomobject ]@ {
371
360
name = $inputJson.Name
372
- uri = $inputJson.Uri
373
- trusted = $inputJson.Trusted
374
- priority = $inputJson.Priority
375
- repositoryType = $inputJson.repositoryType
376
361
_exist = $false
377
362
}
378
363
}
379
364
else {
380
- Write-Trace - message " Populating repository object for: $ ( $RepositoryInfo.Name ) " - Level Verbose
365
+ Write-Trace - message " Populating repository object for: $ ( $RepositoryInfo.Name ) "
381
366
[pscustomobject ]@ {
382
367
name = $RepositoryInfo.Name
383
368
uri = $RepositoryInfo.Uri
0 commit comments