From 6e319ff088181ca9b0d9637acb063b8a6231213c Mon Sep 17 00:00:00 2001 From: Shachaf92 Date: Fri, 5 Jul 2019 01:00:58 +0300 Subject: [PATCH] win_psmodule - Missing SkipPublisherCheck in Prerq installations (#58090) * win_psmodule - Missing SkipPublisherCheck in Prerq installations * Handle different minors of PS5 * community revisions * Update win_psmodule.ps1 --- .../win_psmodule-PreReq-SkipPublisher-missing.yml | 2 ++ lib/ansible/modules/windows/win_psmodule.ps1 | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/win_psmodule-PreReq-SkipPublisher-missing.yml 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