@@ -40,7 +40,7 @@ function Get-DSCResourceModules {
4040 }
4141 }
4242 }
43-
43+
4444 return $dscModulePsd1List
4545}
4646
@@ -83,7 +83,7 @@ function Add-AstMembers {
8383 [DscResourcePropertyInfo ]$prop = [DscResourcePropertyInfo ]::new()
8484 $prop.Name = $property.Name
8585 $prop.PropertyType = $property.PropertyType.TypeName.Name
86- $prop.IsMandatory = $isKeyProperty
86+ $prop.IsMandatory = $isKeyProperty
8787 $Properties.Add ($prop )
8888 }
8989}
@@ -104,7 +104,7 @@ function FindAndParseResourceDefinitions {
104104 if (" .psm1" , " .ps1" -notcontains ([System.IO.Path ]::GetExtension($filePath ))) {
105105 return
106106 }
107-
107+
108108 " Loading resources from file '$filePath '" | Write-DscTrace - Operation Trace
109109 # TODO: Ensure embedded instances in properties are working correctly
110110 [System.Management.Automation.Language.Token []] $tokens = $null
@@ -134,13 +134,13 @@ function FindAndParseResourceDefinitions {
134134 $DscResourceInfo.Module = $filePath
135135 $DscResourceInfo.Path = $filePath
136136 # TODO: ModuleName, Version and ParentPath should be taken from psd1 contents
137- $DscResourceInfo.ModuleName = [System.IO.Path ]::GetFileNameWithoutExtension($filePath )
137+ $DscResourceInfo.ModuleName = [System.IO.Path ]::GetFileNameWithoutExtension($filePath )
138138 $DscResourceInfo.ParentPath = [System.IO.Path ]::GetDirectoryName($filePath )
139139 $DscResourceInfo.Version = $moduleVersion
140140
141141 $DscResourceInfo.Properties = [System.Collections.Generic.List [DscResourcePropertyInfo ]]::new()
142142 Add-AstMembers $typeDefinitions $typeDefinitionAst $DscResourceInfo.Properties
143-
143+
144144 $resourceList.Add ($DscResourceInfo )
145145 }
146146 }
@@ -157,7 +157,7 @@ function LoadPowerShellClassResourcesFromModule {
157157 )
158158
159159 " Loading resources from module '$ ( $moduleInfo.Path ) '" | Write-DscTrace - Operation Trace
160-
160+
161161 if ($moduleInfo.RootModule ) {
162162 if (" .psm1" , " .ps1" -notcontains ([System.IO.Path ]::GetExtension($moduleInfo.RootModule )) -and
163163 (-not $moduleInfo.NestedModules )) {
@@ -190,8 +190,8 @@ function LoadPowerShellClassResourcesFromModule {
190190 This function caches the results of the Get-DscResource call to optimize performance.
191191
192192. DESCRIPTION
193- This function is designed to improve the performance of DSC operations by caching the results of the Get-DscResource call.
194- By storing the results, subsequent calls to Get-DscResource can retrieve the cached data instead of making a new call each time.
193+ This function is designed to improve the performance of DSC operations by caching the results of the Get-DscResource call.
194+ By storing the results, subsequent calls to Get-DscResource can retrieve the cached data instead of making a new call each time.
195195 This can significantly speed up operations that need to repeatedly access DSC resources.
196196
197197. EXAMPLE
@@ -240,7 +240,7 @@ function Invoke-DscCacheRefresh {
240240 foreach ($cacheEntry in $dscResourceCacheEntries ) {
241241
242242 $cacheEntry.LastWriteTimes.PSObject.Properties | ForEach-Object {
243-
243+
244244 if (Test-Path $_.Name ) {
245245 $file_LastWriteTime = (Get-Item $_.Name ).LastWriteTime
246246 # Truncate DateTime to seconds
@@ -289,7 +289,7 @@ function Invoke-DscCacheRefresh {
289289 " Cache file not found '$cacheFilePath '" | Write-DscTrace
290290 $refreshCache = $true
291291 }
292-
292+
293293 if ($refreshCache ) {
294294 ' Constructing Get-DscResource cache' | Write-DscTrace
295295
@@ -306,7 +306,7 @@ function Invoke-DscCacheRefresh {
306306 $processedModuleNames.Add ($mod.Name , $true )
307307
308308 # from several modules with the same name select the one with the highest version
309- $selectedMod = $modules | Where-Object Name -EQ $mod.Name
309+ $selectedMod = $modules | Where-Object Name -EQ $mod.Name
310310 if ($selectedMod.Count -gt 1 ) {
311311 " Found $ ( $selectedMod.Count ) modules with name '$ ( $mod.Name ) '" | Write-DscTrace - Operation Trace
312312 $selectedMod = $selectedMod | Sort-Object - Property Version - Descending | Select-Object - First 1
@@ -407,7 +407,7 @@ function Invoke-DscOperation {
407407
408408 # workaround: script based resources do not validate Get parameter consistency, so we need to remove any parameters the author chose not to include in Get-TargetResource
409409 switch ([dscResourceType ]$cachedDscResourceInfo.ImplementationDetail ) {
410-
410+
411411 ' ClassBased' {
412412 try {
413413 # load powershell class from external module
@@ -424,7 +424,7 @@ function Invoke-DscOperation {
424424 # handle input objects by converting them to a hash table
425425 if ($_.Value -is [System.Management.Automation.PSCustomObject ]) {
426426 $validateProperty = $cachedDscResourceInfo.Properties | Where-Object - Property Name -EQ $_.Name
427- if ($validateProperty.PropertyType -eq ' PSCredential' ) {
427+ if ($validateProperty -and $validateProperty .PropertyType -eq ' PSCredential' ) {
428428 if (-not $_.Value.Username -or -not $_.Value.Password ) {
429429 " Credential object '$ ( $_.Name ) ' requires both 'username' and 'password' properties" | Write-DscTrace - Operation Error
430430 exit 1
@@ -453,7 +453,7 @@ function Invoke-DscOperation {
453453 }
454454 ' Test' {
455455 $Result = $dscResourceInstance.Test ()
456- $addToActualState.properties = [psobject ]@ {' InDesiredState' = $Result }
456+ $addToActualState.properties = [psobject ]@ {' InDesiredState' = $Result }
457457 }
458458 ' Export' {
459459 $t = $dscResourceInstance.GetType ()
@@ -464,7 +464,7 @@ function Invoke-DscOperation {
464464 break
465465 }
466466 }
467-
467+
468468 if ($null -eq $method ) {
469469 " Export method not implemented by resource '$ ( $DesiredState.Type ) '" | Write-DscTrace - Operation Error
470470 exit 1
@@ -481,7 +481,7 @@ function Invoke-DscOperation {
481481 }
482482 }
483483 catch {
484-
484+
485485 ' Exception: ' + $_.Exception.Message | Write-DscTrace - Operation Error
486486 exit 1
487487 }
0 commit comments