Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Windows Management Framework (WMF) 5.1 #106

Closed
jugatsu opened this issue Mar 20, 2017 · 10 comments
Closed

Add support for Windows Management Framework (WMF) 5.1 #106

jugatsu opened this issue Mar 20, 2017 · 10 comments

Comments

@jugatsu
Copy link
Contributor

jugatsu commented Mar 20, 2017

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?

@jugatsu
Copy link
Contributor Author

jugatsu commented Mar 29, 2017

@tas50 what do you think about this? I can start WIP PR for wmf5.1.

@jugatsu
Copy link
Contributor Author

jugatsu commented Mar 29, 2017

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.

@smurawski
Copy link
Contributor

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.

@smurawski smurawski self-assigned this Mar 31, 2017
@smurawski
Copy link
Contributor

I'm working on this now.

@jugatsu
Copy link
Contributor Author

jugatsu commented Apr 24, 2017

@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'

@jugatsu
Copy link
Contributor Author

jugatsu commented Apr 24, 2017

@jugatsu
Copy link
Contributor Author

jugatsu commented Apr 26, 2017

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 }

@silverl
Copy link

silverl commented May 28, 2017

The support deadline for WMF 5.0 is a few days away (June 2017). Any news on WMF 5.1? Thanks.

@jugatsu
Copy link
Contributor Author

jugatsu commented May 30, 2017

@smurawski any progress on this issue? can i help with testing?

@smurawski
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants