diff --git a/changelogs/fragments/win_psmodule-PreReq-SkipPublisher-missing.yml b/changelogs/fragments/win_psmodule-PreReq-SkipPublisher-missing.yml new file mode 100644 index 00000000000..f6bad58b748 --- /dev/null +++ b/changelogs/fragments/win_psmodule-PreReq-SkipPublisher-missing.yml @@ -0,0 +1,2 @@ +bugfixes: + - "win_psmodule - Missing SkipPublisherCheck in Prerq installations" \ No newline at end of file diff --git a/lib/ansible/modules/windows/win_psmodule.ps1 b/lib/ansible/modules/windows/win_psmodule.ps1 index 8fc3ca7e67c..b24178e49ff 100644 --- a/lib/ansible/modules/windows/win_psmodule.ps1 +++ b/lib/ansible/modules/windows/win_psmodule.ps1 @@ -69,7 +69,17 @@ Function Install-PrereqModule { } else { try { - Install-Module -Name $Name -MinimumVersion $PrereqModules[$Name] -Force -WhatIf:$CheckMode | Out-Null + $install_params = @{ + Name = $Name + MinimumVersion = $PrereqModules[$Name] + Force = $true + WhatIf = $CheckMode + } + if ((Get-Command -Name Install-Module).Parameters.ContainsKey('SkipPublisherCheck')) { + $install_params.SkipPublisherCheck = $true + } + + Install-Module @install_params > $null if ( $Name -eq 'PowerShellGet' ) { # An order has to be reverted due to dependency