@@ -104,23 +104,25 @@ class PSResource {
104104 [OrderedDictionary ] ToData([bool ]$forTest ) {
105105 $data = [OrderedDictionary ]::new()
106106
107- $data. name = $this.name
107+ $data [ ' name' ] = $this.name
108108 if (-not [string ]::IsNullOrEmpty($this.version )) {
109- $data. version = $this.version
109+ $data [ ' version' ] = $this.version
110110 }
111- $data. scope = $this.scope
111+ $data [ ' scope' ] = $this.scope
112112 if (-not [string ]::IsNullOrEmpty($this.repositoryName )) {
113- $data.repositoryName = $this.repositoryName
113+ $data [' repositoryName' ] = $this.repositoryName
114+ } else {
115+ $data [' repositoryName' ] = " "
114116 }
115- $data. preRelease = $this.preRelease
116- $data. _exist = $this._exist
117+ $data [ ' preRelease' ] = $this.preRelease
118+ $data [ ' _exist' ] = $this._exist
117119
118120 if ($forTest ) {
119- $data. _inDesiredState = $this._inDesiredState
121+ $data [ ' _inDesiredState' ] = $this._inDesiredState
120122 }
121123
122124 if ($null -ne $this._metadata ) {
123- $data. _metadata = $this._metadata
125+ $data [ ' _metadata' ] = $this._metadata
124126 }
125127
126128 return $data
@@ -212,6 +214,8 @@ class PSResourceList {
212214 $data = [OrderedDictionary ]::new()
213215 if (-not [string ]::IsNullOrEmpty($this.repositoryName )) {
214216 $data [' repositoryName' ] = $this.repositoryName
217+ } else {
218+ $data [' repositoryName' ] = " "
215219 }
216220 if ($this.resources ) {
217221 [OrderedDictionary []] $resourceData = $this.resources | ForEach-Object { $_.ToData ($forTest ) }
@@ -302,8 +306,10 @@ class Repository {
302306 if (-not [string ]::IsNullOrEmpty($this.uri )) {
303307 $data [' uri' ] = $this.uri
304308 }
305- $data [' trusted' ] = $this.trusted
306- $data [' priority' ] = $this.priority
309+ if ($this._exist ) {
310+ $data [' trusted' ] = $this.trusted
311+ $data [' priority' ] = $this.priority
312+ }
307313 if (-not [string ]::IsNullOrEmpty($this.repositoryType )) {
308314 $data [' repositoryType' ] = $this.repositoryType
309315 }
@@ -1013,7 +1019,7 @@ function PopulatePSResourceListObject {
10131019
10141020 $allPSResources = @ ()
10151021
1016- if ($allUsersPSResources.count -gt 1 ) {
1022+ if (@ ( $allUsersPSResources ) .count -gt 0 ) {
10171023 $allPSResources += $allUsersPSResources | ForEach-Object {
10181024 return [PSResource ]::new(
10191025 $_.Name ,
@@ -1027,7 +1033,7 @@ function PopulatePSResourceListObject {
10271033 Write-Trace - level info " No PSResources found for AllUsers scope."
10281034 }
10291035
1030- if ($currentUserPSResources.count -gt 1 ) {
1036+ if (@ ( $currentUserPSResources ) .count -gt 0 ) {
10311037 $allPSResources += $currentUserPSResources | ForEach-Object {
10321038 return [PSResource ]::new(
10331039 $_.Name ,
0 commit comments