{"id":19055,"date":"2021-06-16T08:29:05","date_gmt":"2021-06-16T16:29:05","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/powershell\/?p=19055"},"modified":"2021-06-16T09:39:11","modified_gmt":"2021-06-16T17:39:11","slug":"preview-updating-powershell-7-2-with-microsoft-update","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/preview-updating-powershell-7-2-with-microsoft-update\/","title":{"rendered":"Preview updating PowerShell 7.2 with Microsoft Update"},"content":{"rendered":"<h2>Updating PowerShell 7 with Microsoft Update<\/h2>\n<p>Today, we&#8217;re happy to announce that we&#8217;re taking the first steps to making PowerShell 7 easier than ever to update on Windows 10 and Server. In the past, Windows users were <em>notified<\/em> in their console that a new version of PowerShell 7 is available, but they still had to hop over to our <a href=\"https:\/\/github.com\/PowerShell\/PowerShell\/releases\">GitHub release page to download and install it<\/a>, or rely on a separate package management tool like the <a href=\"https:\/\/github.com\/microsoft\/winget-cli\">Windows Package Manager<\/a>, <a href=\"https:\/\/community.chocolatey.org\/packages\/powershell-core\">Chocolatey<\/a>, or <a href=\"https:\/\/scoop.sh\/\">Scoop<\/a>. But with <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/deployment\/update\/waas-configure-wufb#configure-when-devices-receive-quality-updates\">Microsoft Update<\/a>, you&#8217;ll get the latest PowerShell 7 updates directly in your traditional Windows Update (WU) management flow, whether that&#8217;s with Windows Update for Business, WSUS, SCCM, or the interactive WU dialog in Settings. With today&#8217;s announcement, you&#8217;ll soon be able to try this new update process for yourself\non the latest PowerShell 7.2 previews.<\/p>\n<h2>How updates will work<\/h2>\n<p>Because of the large changes and validation required to get this to work, we will publish updates only for future releases. We have already been working on a release that updates 7.2 preview 5 or newer to 7.2 preview 7. We will begin the Microsoft Update publishing process once we release an update to GitHub.<\/p>\n<h2>How you can opt-in and help test the upgrade<\/h2>\n<p>First, you&#8217;ll need to have Windows 10 RS3 (10.0.16299) or newer installed, as well as PowerShell 7.2 preview.5 or preview.6 installed. You&#8217;ll also need to ensure that your machine is set up to receive Microsoft Update updates. (On Windows 10, this is done by going to Settings -&gt; Windows Update -&gt; Advanced options and checking &#8220;Receive updates for other Microsoft products when you update Windows.&#8221; Next, you&#8217;ll need to make sure not to update to the latest 7.2 preview.7 or greater using the MSI. Finally, you&#8217;ll need to add a specific registry key to opt-in to Microsoft Update usage for PS7. Running the following script from an elevated PowerShell session will setup the registry for this scenario:<\/p>\n<pre><code class=\"language-powershell\"><span class=\"hljs-variable\">$pwshRegPath<\/span> = <span class=\"hljs-string\">\"HKLM:\\SOFTWARE\\Microsoft\\PowerShellCore\"<\/span>\r\nif (!(Test-Path -Path $pwshRegPath)) {\r\n    throw \"PowerShell 7 is not installed\"\r\n}\r\n\r\nSet-ItemProperty -Path $pwshRegPath -Name UseMU -Value 1 -Type DWord<\/code><\/pre>\n<p>About a week after PowerShell 7.2 preview.7 update is released, <a href=\"https:\/\/twitter.com\/PowerShell_Team\">@PowerShell_Team <\/a>will tweet that the Microsoft Update release is available. At this point, you should be prompted to update PowerShell 7.2-preview in your standard Windows Update workflow.<\/p>\n<h2>Test new installs of PowerShell 7.2 preview<\/h2>\n<p>If you don&#8217;t already have PowerShell 7.2 preview installed, you can still help us try out a new install method! Again, you&#8217;ll need to have Windows 10 RS3 (10.0.16299) or newer installed and Microsoft Update enabled. Then, run the following script from an elevated PowerShell session to setup the registry in such a way that Microsoft Update will install and update the latest version of PowerShell 7 preview. Running the following script from an elevated PowerShell session, will setup the registry for this scenario:<\/p>\n<pre><code class=\"language-powershell\"><span class=\"hljs-variable\">$pwshRegPath<\/span> = <span class=\"hljs-string\">\"HKLM:\\SOFTWARE\\Microsoft\\PowerShellCore\"<\/span>\r\n<span class=\"hljs-variable\">$previewPath<\/span> = <span class=\"hljs-built_in\">Join-Path<\/span> <span class=\"hljs-literal\">-Path<\/span> <span class=\"hljs-variable\">$pwshRegPath<\/span> <span class=\"hljs-literal\">-ChildPath<\/span> <span class=\"hljs-string\">\"InstalledVersions\\39243d76-adaf-42b1-94fb-16ecf83237c8\"<\/span>\r\nif (!(Test-Path -Path $previewPath)) {\r\n    $null = New-Item -Path $previewPath -ItemType Directory -Force\r\n}\r\n\r\nSet-ItemProperty -Path $pwshRegPath -Name UseMU -Value 1 -Type DWord\r\nSet-ItemProperty -Path $previewPath -Name Install -Value 1 -Type DWord<\/code><\/pre>\n<p>Note: due to an issue with the installer, make sure to uninstall any previously installed version of the PowerShell Preview MSI.<\/p>\n<p>Also, as noted in the previous section, this will not work until <a href=\"https:\/\/twitter.com\/PowerShell_Team\">@PowerShell_Team<\/a> tweets that the 7.2 preview.7 MU release is live.<\/p>\n<h2>If you want to disable either scenario<\/h2>\n<p>If you hit an issue that is bad enough you want to disable MU-based install or updates, run the following script from an elevated PowerShell session:<\/p>\n<pre><code class=\"language-powershell\"><span class=\"hljs-variable\">$pwshRegPath<\/span> = <span class=\"hljs-string\">\"HKLM:\\SOFTWARE\\Microsoft\\PowerShellCore\"<\/span>\r\n<span class=\"hljs-variable\">$previewPath<\/span> = <span class=\"hljs-built_in\">Join-Path<\/span> <span class=\"hljs-literal\">-Path<\/span> <span class=\"hljs-variable\">$pwshRegPath<\/span> <span class=\"hljs-literal\">-ChildPath<\/span> <span class=\"hljs-string\">\"InstalledVersions\\39243d76-adaf-42b1-94fb-16ecf83237c8\"<\/span>\r\nif (!(Test-Path -Path $previewPath)) {\r\n    throw \"PowerShell 7 Preview is not installed\"\r\n}\r\n\r\nSet-ItemProperty -Path $pwshRegPath -Name UseMU -Value 0 -Type DWord\r\nSet-ItemProperty -Path $previewPath -Name Install -Value 0 -Type DWord<\/code><\/pre>\n<h2>Final words<\/h2>\n<p>Going forward we are working to remove the need to manually add the <code>UseMU<\/code> registry value.<\/p>\n<p>If you try either scenario and it works, please upvote the <a href=\"https:\/\/github.com\/PowerShell\/PowerShell\/discussions\/15510\">Microsoft Update discussion<\/a>. If you have any issue, please <a href=\"https:\/\/github.com\/PowerShell\/PowerShell\/issues\/new\/choose\">file an issue<\/a> and link it in the discussion above.<\/p>\n<p>Thanks for all your help,<\/p>\n<p>Travis Plunk<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We are going to begin previewing our updates to PowerShell 7 with Microsoft Update.<\/p>\n","protected":false},"author":2752,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[248],"class_list":["post-19055","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-powershell"],"acf":[],"blog_post_summary":"<p>We are going to begin previewing our updates to PowerShell 7 with Microsoft Update.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/19055","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/2752"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=19055"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/19055\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=19055"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=19055"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=19055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}