@@ -146,7 +146,10 @@ function Get-TargetResource {
146146 # Check if the repository matches.
147147 $repositoryName = Get-ModuleRepositoryName - Module $latestModule - ErrorAction SilentlyContinue - WarningAction SilentlyContinue
148148
149- $installationPolicy = Get-InstallationPolicy - RepositoryName $repositoryName - ErrorAction SilentlyContinue - WarningAction SilentlyContinue
149+ if ($repositoryName ) {
150+ $installationPolicy = Get-InstallationPolicy - RepositoryName $repositoryName - ErrorAction SilentlyContinue - WarningAction SilentlyContinue
151+ }
152+
150153 if ($installationPolicy ) {
151154 $installationPolicyReturnValue = ' Trusted'
152155 }
@@ -389,7 +392,7 @@ function Set-TargetResource {
389392 $extractedArguments = New-SplatParameterHashTable - FunctionBoundParameters $PSBoundParameters `
390393 - ArgumentNames (' MinimumVersion' , ' MaximumVersion' , ' RequiredVersion' )
391394
392- Test-VersionParameter @extractedArguments
395+ $null = Test-VersionParameter @extractedArguments
393396
394397 try {
395398 $extractedArguments = New-SplatParameterHashTable - FunctionBoundParameters $PSBoundParameters `
@@ -426,7 +429,7 @@ function Set-TargetResource {
426429 # Extract the installation options.
427430 $extractedSwitches = New-SplatParameterHashTable - FunctionBoundParameters $PSBoundParameters - ArgumentNames (' Force' , ' AllowClobber' , ' SkipPublisherCheck' )
428431
429- $moduleFound | Install-Module @extractedSwitches
432+ $moduleFound | Install-Module @extractedSwitches 2>&1 | out-string | Write-Verbose
430433 }
431434 # The repository is untrusted but user's installation policy is trusted, so we install it with a warning.
432435 elseif ($InstallationPolicy -ieq ' Trusted' ) {
@@ -436,7 +439,7 @@ function Set-TargetResource {
436439 $extractedSwitches = New-SplatParameterHashTable - FunctionBoundParameters $PSBoundParameters - ArgumentNames (' AllowClobber' , ' SkipPublisherCheck' )
437440
438441 # If all the repositories are untrusted, we choose the first one.
439- $modules [0 ] | Install-Module @extractedSwitches - Force
442+ $modules [0 ] | Install-Module @extractedSwitches - Force 2>&1 | out-string | Write-Verbose
440443 }
441444 # Both user and repository is untrusted
442445 else {
0 commit comments