From 3e35b26e53451642fc7f55fe32cf60c22dc457c9 Mon Sep 17 00:00:00 2001 From: Brian Scholer Date: Sat, 8 Jul 2017 15:07:41 -0400 Subject: [PATCH 1/2] Update module import semantics for #9 --- Idempotion.psd1 | Bin 7908 -> 7908 bytes Public/Convert-DscResourceToCommand.ps1 | 7 ++++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Idempotion.psd1 b/Idempotion.psd1 index 79446cc9abedfada45c93c5b83dc32d582965ed0..0a9a0d07d820bd4a6026e1da1526a6fa0178cc39 100644 GIT binary patch delta 18 ZcmaE2`^0vG0TZhsgC2vyW>cp1G5|cL1#SQU delta 18 ZcmaE2`^0vG0TZhMgC2w7W>cp1G5|cH1#SQU diff --git a/Public/Convert-DscResourceToCommand.ps1 b/Public/Convert-DscResourceToCommand.ps1 index fdb80cd..e5bef9b 100644 --- a/Public/Convert-DscResourceToCommand.ps1 +++ b/Public/Convert-DscResourceToCommand.ps1 @@ -272,7 +272,12 @@ param( $newMod | Remove-Module -Force -Verbose:$VerbosePreference if ($Import) { # PassThru will be in $ipmoParams so the module will be returned if needed - $newMod | Import-Module @ipmoParams -Global -Verbose:$VerbosePreference + if ($Force) { + Remove-Module -Name $newMod.Name -Force -ErrorAction Ignore + } + if ($Force -or -not (Get-Module -Name $newMod.Name -ErrorAction Ignore)) { + $newMod | Import-Module @ipmoParams -Global -Verbose:$VerbosePreference + } } else { $newMod # module is always returned if it's not imported } From 1fa0ef770d295868a8eccb505ce06d45605c73f9 Mon Sep 17 00:00:00 2001 From: Brian Scholer Date: Sat, 8 Jul 2017 15:11:47 -0400 Subject: [PATCH 2/2] Update Verbose semantics in fix for #9 --- Public/Convert-DscResourceToCommand.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Public/Convert-DscResourceToCommand.ps1 b/Public/Convert-DscResourceToCommand.ps1 index e5bef9b..20a2dcb 100644 --- a/Public/Convert-DscResourceToCommand.ps1 +++ b/Public/Convert-DscResourceToCommand.ps1 @@ -251,7 +251,7 @@ param( $ipmoParams[$paramName] = $PSBoundParameters[$paramName] } - $newMod = New-Module @nmoParams -Verbose:$VerbosePreference + $newMod = New-Module @nmoParams -Verbose:$false if ($AsCustomObject) { # Just return it directly if we opted for a custom object $newMod @@ -269,11 +269,11 @@ param( If it shouldn't be imported, then we leave it removed and return it to the caller. #> - $newMod | Remove-Module -Force -Verbose:$VerbosePreference + $newMod | Remove-Module -Force -Verbose:$false if ($Import) { # PassThru will be in $ipmoParams so the module will be returned if needed if ($Force) { - Remove-Module -Name $newMod.Name -Force -ErrorAction Ignore + Remove-Module -Name $newMod.Name -Force -ErrorAction Ignore -Verbose:$VerbosePreference } if ($Force -or -not (Get-Module -Name $newMod.Name -ErrorAction Ignore)) { $newMod | Import-Module @ipmoParams -Global -Verbose:$VerbosePreference