@@ -146,7 +146,10 @@ function Get-TargetResource {
146
146
# Check if the repository matches.
147
147
$repositoryName = Get-ModuleRepositoryName - Module $latestModule - ErrorAction SilentlyContinue - WarningAction SilentlyContinue
148
148
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
+
150
153
if ($installationPolicy ) {
151
154
$installationPolicyReturnValue = ' Trusted'
152
155
}
@@ -389,7 +392,7 @@ function Set-TargetResource {
389
392
$extractedArguments = New-SplatParameterHashTable - FunctionBoundParameters $PSBoundParameters `
390
393
- ArgumentNames (' MinimumVersion' , ' MaximumVersion' , ' RequiredVersion' )
391
394
392
- Test-VersionParameter @extractedArguments
395
+ $null = Test-VersionParameter @extractedArguments
393
396
394
397
try {
395
398
$extractedArguments = New-SplatParameterHashTable - FunctionBoundParameters $PSBoundParameters `
@@ -426,7 +429,7 @@ function Set-TargetResource {
426
429
# Extract the installation options.
427
430
$extractedSwitches = New-SplatParameterHashTable - FunctionBoundParameters $PSBoundParameters - ArgumentNames (' Force' , ' AllowClobber' , ' SkipPublisherCheck' )
428
431
429
- $moduleFound | Install-Module @extractedSwitches
432
+ $moduleFound | Install-Module @extractedSwitches 2>&1 | out-string | Write-Verbose
430
433
}
431
434
# The repository is untrusted but user's installation policy is trusted, so we install it with a warning.
432
435
elseif ($InstallationPolicy -ieq ' Trusted' ) {
@@ -436,7 +439,7 @@ function Set-TargetResource {
436
439
$extractedSwitches = New-SplatParameterHashTable - FunctionBoundParameters $PSBoundParameters - ArgumentNames (' AllowClobber' , ' SkipPublisherCheck' )
437
440
438
441
# 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
440
443
}
441
444
# Both user and repository is untrusted
442
445
else {
0 commit comments