@@ -78,10 +78,12 @@ class ResourceBase
7878
7979 $dscResourceObject = [System.Activator ]::CreateInstance($this.GetType ())
8080
81+ $currentStateResultKeys = @ ($getCurrentStateResult.Keys )
82+
8183 # Set values returned from the derived class' GetCurrentState().
8284 foreach ($propertyName in $this.PSObject.Properties.Name )
8385 {
84- if ($propertyName -in @ ( $getCurrentStateResult .Keys ) -and $null -ne $getCurrentStateResult .$propertyName )
86+ if ($propertyName -in $currentStateResultKeys -and $null -ne $getCurrentStateResult .$propertyName )
8587 {
8688 $dscResourceObject .$propertyName = $getCurrentStateResult .$propertyName
8789 }
@@ -92,7 +94,7 @@ class ResourceBase
9294 # Set key property values unless it was returned from the derived class' GetCurrentState().
9395 foreach ($propertyName in $this.CachedKeyProperties.Keys )
9496 {
95- if ($propertyName -notin @ ( $getCurrentStateResult .Keys ) )
97+ if ($propertyName -notin $currentStateResultKeys )
9698 {
9799 # Add the key value to the instance to be returned.
98100 $dscResourceObject .$propertyName = $this .$propertyName
@@ -157,10 +159,10 @@ class ResourceBase
157159 # The Get() method is called by Test().
158160 $propertiesToModify = $this.PropertiesNotInDesiredState | ConvertFrom-CompareResult
159161
160- $ propertiesToModify.Keys |
161- ForEach-Object - Process {
162- Write-Verbose - Message ($this.localizedData.SetProperty -f $_ , $propertiesToModify .$_ )
163- }
162+ foreach ( $property in $ propertiesToModify.Keys )
163+ {
164+ Write-Verbose - Message ($this.localizedData.SetProperty -f $property , $propertiesToModify .$property )
165+ }
164166
165167 <#
166168 Call the Modify() method with the properties that should be enforced
@@ -202,7 +204,7 @@ class ResourceBase
202204 CurrentValues = $currentState
203205 DesiredValues = $this.CachedDesiredState
204206 Properties = $this.CachedDesiredState.Keys
205- ExcludeProperties = ( $excludeProperties + $this.ExcludeDscProperties ) | Select -Object - Unique
207+ ExcludeProperties = @ (( $excludeProperties + $this.ExcludeDscProperties ) | Sort -Object - Unique)
206208 IncludeValue = $true
207209 # This is needed to sort complex types.
208210 SortArrayValues = $true
0 commit comments