77 [ValidateSet (' repository' , ' psresource' , ' repositories' , ' psresources' )]
88 [string ]$ResourceType ,
99 [Parameter (Mandatory = $true )]
10- [ValidateSet (' get' , ' set' , ' export ' , ' test ' )]
10+ [ValidateSet (' get' , ' set' , ' test ' , ' export ' )]
1111 [string ]$Operation ,
1212 [Parameter (ValueFromPipeline )]
1313 $stdinput
@@ -16,28 +16,17 @@ param(
1616function Write-Trace {
1717 param (
1818 [string ]$message ,
19- [string ]$level = ' Error'
19+
20+ [ValidateSet (' error' , ' warn' , ' info' , ' debug' , ' trace' )]
21+ [string ]$level = ' trace'
2022 )
2123
2224 $trace = [pscustomobject ]@ {
2325 $level.ToLower () = $message
2426 } | ConvertTo-Json - Compress
2527
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+
4130}
4231
4332# catch any un-caught exception and write it to the error stream
@@ -194,14 +183,14 @@ function SetPSResources {
194183 }
195184
196185 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 ) " }) "
198187 $resourcesToUninstall | ForEach-Object {
199188 Uninstall-PSResource - Name $_.Name - Scope $scope - ErrorAction Stop
200189 }
201190 }
202191
203192 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 ) " }) "
205194 $resourcesToInstall.Values | ForEach-Object {
206195 Install-PSResource - Name $_.Name - Version $_.Version - Scope $scope - Repository $repositoryName - ErrorAction Stop
207196 }
@@ -363,21 +352,17 @@ function PopulateRepositoryObject {
363352 )
364353
365354 $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"
367356
368357 $inputJson = $stdinput | ConvertFrom-Json - ErrorAction Stop
369358
370359 [pscustomobject ]@ {
371360 name = $inputJson.Name
372- uri = $inputJson.Uri
373- trusted = $inputJson.Trusted
374- priority = $inputJson.Priority
375- repositoryType = $inputJson.repositoryType
376361 _exist = $false
377362 }
378363 }
379364 else {
380- Write-Trace - message " Populating repository object for: $ ( $RepositoryInfo.Name ) " - Level Verbose
365+ Write-Trace - message " Populating repository object for: $ ( $RepositoryInfo.Name ) "
381366 [pscustomobject ]@ {
382367 name = $RepositoryInfo.Name
383368 uri = $RepositoryInfo.Uri
0 commit comments