Skip to content

Commit

Permalink
Merge pull request #112 from michaeltlombardi/gh-110/main/psgroup-ver…
Browse files Browse the repository at this point in the history
…sion-handling

(GH-110) Handle missing PSDesiredStateConfiguration module for ps group resource
  • Loading branch information
SteveL-MSFT authored Aug 2, 2023
2 parents a066d11 + 09e2e63 commit 5fa5f5b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion powershellgroup/powershellgroup.resource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,20 @@ function RefreshCache
}
}

Import-Module PSDesiredStateConfiguration
$DscModule = Get-Module -Name PSDesiredStateConfiguration -ListAvailable |
Sort-Object -Property Version -Descending |
Select-Object -First 1

if ($null -eq $DscModule)
{
Write-Error "Could not find and import the PSDesiredStateConfiguration module."
# Missing module is okay for listing resources
if ($Operation -eq 'List') { exit 0 }

exit 1
}

Import-Module $DscModule

if ($Operation -eq 'List')
{
Expand Down

0 comments on commit 5fa5f5b

Please sign in to comment.