Closed jugatsu closed 7 years ago
@tas50 what do you think about this? I can start WIP PR for wmf5.1.
As per today announcement https://blogs.msdn.microsoft.com/powershell/2017/03/28/windows-management-framework-wmf-5-1-now-in-microsoft-update-catalog/ WMF5.0 will be removed from Download Center as of June 1, 2017.
As previously announced, WMF 5.1 is a required update for WMF 5.0, and may be installed directly over WMF 5.0. As of June 1, 2017, users with WMF 5.0 must upgrade to WMF 5.1 to receive support. At that time, WMF 5.0 will be removed from the Download Center and from the WSUS catalog.
I think we should deprecate wmf5.0 in powershell5
recipe until this time.
There's work progress on this cookbook (and some of it's dependencies) in prep for Chef 13. We can remove wmf 5 support and update to wmf 5.1 as part of that process.
I'm working on this now.
@smurawski I'm just testing mwf 5.1 on windows 6.1 and found a nasty bug after powershell 5.1 was installed on windows 7 sp1 (doesn't testing 2008r2 yet). Default Powershell Configuration Session, Microsoft.powershell has been unregistered and there is only Microsoft.powershell.workflow registered. And therefore test-kitchen can't connect after succefully converge and reboot as WinRM doesn't accept connections.
As a workaround
# NOTE: add hotfix to Microsoft.powershell bug after WMF5.1 installation
# as Test-Kitchen couldn't connect via WinRM after reboot
if ENV['TEST_KITCHEN']
registry_key 'HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce' do
values [
{ name: '!FixPowershell5', type: :string, data: "C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -ExecutionPolicy Bypass -NonInteractive -Command \"sleep 120; Register-PSSessionConfiguration -Name Microsoft.powershell -Force\"" },
]
only_if { powershell_out("$PSVersionTable.PSVersion.Major").stdout.strip.to_i < 5 }
action :create
end
end
# ensure Microsoft.powershell is enabled after WMF5.1 installation
powershell_script 'Register Microsoft.powershell session configuration' do
code 'Register-PSSessionConfiguration -Name Microsoft.powershell -Force'
not_if '(Get-PSSessionConfiguration -Name microsoft.powershell) -ne $null'
action :run
end
include_recipe 'ms_dotnet::ms_dotnet4'
include_recipe 'powershell::powershell5'
Here we go
# NOTE: add hotfix to Microsoft.powershell bug after WMF5.1 installation
# as Test-Kitchen couldn't connect via WinRM after reboot
cmd = 'C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe'
cmd << " -NoProfile -Executionpolicy Bypass -NonInteractive -Command \"sleep 120;"
cmd << " Register-PSSessionConfiguration -Name Microsoft.powershell -Force\""
if ENV['TEST_KITCHEN']
registry_key 'HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce' do
values [
{ name: '!FixPowershell5', type: :string, data: cmd },
]
only_if { powershell_out('$PSVersionTable.PSVersion.Major').stdout.strip.to_i < 5 }
action :create
end
end
# ensure Microsoft.powershell is enabled after WMF5.1 installation
powershell_script 'Register Microsoft.powershell session configuration' do
code 'Register-PSSessionConfiguration -Name Microsoft.powershell -Force'
not_if '(Get-PSSessionConfiguration -Name microsoft.powershell) -ne $null'
not_if { powershell_out('$PSVersionTable.PSVersion.Major').stdout.strip.to_i < 5 }
action :run
end
include_recipe 'ms_dotnet::ms_dotnet4'
include_recipe 'powershell::powershell5'
To workaround Access denied
in WMF 2.0 when running Get-PSSessionConfiguration
under System
account I'm using second not_if guard
not_if { powershell_out('$PSVersionTable.PSVersion.Major').stdout.strip.to_i < 5 }
The support deadline for WMF 5.0 is a few days away (June 2017). Any news on WMF 5.1? Thanks.
@smurawski any progress on this issue? can i help with testing?
Sorry, I got hung up on some other stuff a while back. I'll start back up on this tomorrow and get a release out with 5.1.
WMF 5.1 has been released few month ago https://blogs.msdn.microsoft.com/powershell/2017/01/19/windows-management-framework-wmf-5-1-released/
I have a question to discuss: what is the best naming convention for new recipe for support wmf 5.1?
powershell51
? Or 5.0 should be depricated?