Update your Windows 11 with some powerful One-liners!

Windows update asks you now and then to reboot after installing the latest updates. And then you are up to date? No, not really! There are more things than Windows in your computer that needs to be updated. We have for example all third-party applications, are they up to date? If you look into Defender for Endpoint portal, you get some tips on existing vulnerabilities in your environment due to badly updated softwares. I have gathered some info and One-liners to update more in your Modern Workplace based on Windows rather than just Windows itself.

Windows Update

Windows Update is probably the first thing you think about when discussing updating Windows. So, let’s start with that one. We can use the built in command wuauclt.exe to trigger an update.

Update windows by running this One-liner:

Wuauclt /dectectnow /updatenow

You can also use the PSWindowsUpdate module for Powershell. With this module you can customize your Windows Update request to get exactly what you want. You need to install the Powershell Module with:

Install-module PSWindowsUpdate

Then you can use PowerShell to update Windows from Microsoft Update with this One-liner:

Install-WindowsUpdate -AcceptAll -MicrosoftUpdate -Install -AutoReboot


Winget command line tool that can discover, install, upgrade, remove and configure applications on Windows 10/11. This tool is the client interface to the Windows Package Manager service. This tool is now also used in Microsoft Intune to Deploy and Manage software from the new Microsoft Store. You can verify if Winget is installed in your computer by opening PowerShell and run:

winget --version

If Winget is missing, install built-in Winget and update it from Microsoft Store with this One-liner:

Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe;winget install "App Installer" -s msstore

Update Third-party Applications

Now we can use Winget to update third-party applications. We cannot update them all, they need to exist in the repository. But it will usually update alot!

Update third-party applications with this One-liner

winget upgrade --all --accept-source-agreements --accept-package-agreements

This will update applications that have a new version of the app in repository. You can also force Winget to update all applications that does not report a version in the registry for Windows Apps & Features by adding the flag “–include-unknown”. But it will then update these apps even if they already are up to date.

winget upgrade --all --include-unknown

Microsoft Store Apps

The Microsoft Store App have their own update procedure. You can open Microsoft Store, select your library and check for updates. But you can also trigger this in PowerShell.

To update all your Microsoft Store App run this One-liner:

Get-CimInstance -Namespace "Root\cimv2\mdm\dmmap" -ClassName "MDM_EnterpriseModernAppManagement_AppManagement01" | Invoke-CimMethod -MethodName UpdateScanMethod 

Microsoft 365 apps

Also Microsoft 365 app will update on a regular schedule. but you can of course trigger this to happen when you want it to happen and with a single line of text in PowerShell.

To trigger Microsoft 365 App update run this One-liner:

& 'C:\Program Files\Common Files\microsoft shared\ClickToRun\OfficeC2RClient.exe' /update user displaylevel=false forceappshutdown=true

Microsoft Intune

What if your computer is managed by Intune and you want to get the latest apps and policies. Then you just trigger a scheduled task to start a new sync with Intune!

To sync with Intune and get the latest assigned apps, run this One-liner:

Get-ScheduledTask -TaskName "PushLaunch" | Start-ScheduledTask

But there is also an Intune Management Extension that handles all the Win32 app deployments.

To trigger Intune Management Extension to deploy and install apps from Intune, run this One-liner:

(New-Object -ComObject Shell.Application).open("intunemanagementextension://syncapp")

PowerShell Modules

If you like me are running a lot of PowerShell, it is crucial to keep all PowerShell modules up to date. These are not updated with Windows Update so you need to do it manually. To update PowerShell modules you use the “update-module” command.

Update all your PowerShell modules and remove old version with this One-liner (This will take long time!):

Get-InstalledModule |%{if((get-module -listavailable -name $_.name).version -lt (find-module $_.name).version){update-module -name $_.name -force;Get-InstalledModule -name $_.name -allversions| where {$_.version -lt (get-installedmodule -name $_.name).version} | Uninstall-Module -force}}

I´m working a lot with Microsoft 365 and Azure, I also have this One-liner that I use when reinstalling or replacing my computer that will install and update the most relevant Microsoft 365 and Azure modules.

Install and/or update all Microsoft 365 Powershell modules with this One-liner:

@("MsOnline","ExchangeOnlineManagement","AzureAD","AzureRM","Az","Microsoft.Graph","MicrosoftTeams","Microsoft.Online.SharePoint.PowerShell","Microsoft.PowerApps.Administration.PowerShell","Microsoft.PowerApps.PowerShell","WhiteboardAdmin","O365CentralizedAddInDeployment","PnP.PowerShell","MicrosoftPowerBIMgmt")|%{if(!(get-module -listavailable -name $_)){install-module -name $_ -skippublishercheck -allowclobber -force}elseif((get-module -listavailable -name $_).version -lt (find-module $_).version){update-module -name $_ -force;Get-InstalledModule -name $_ -allversions| where {$_.version -lt (get-installedmodule -name $_.name).version} | Uninstall-Module -force}}

Bonus – PowerShell 7

PowerShell 5.1 is built in with Windows 11. PowerShell 5.1 will be updated together with Windows Updates. But Microsoft has also released a new more powerful PowerShell, PowerShell Core. PowerShell is a different platform than the built-in Windows PowerShell. This means you cannot upgrade the built-in PowerShell to PowerShell Core 7. PowerShell Core 7 will install separately from the built-in PowerShell and runs side by side. A god tip is to run your scripts in both platforms to verify compatibility befor start using in production.

Install PowerShell Core 7 With this One-liner:

winget install --id Microsoft.Powershell --source winget

About Post Author

Mr T-bone

Torbjörn Tbone Granheden is a Solution Architect for Modern Workplace at Coligo AB. Most Valuable Professional (MVP) on Enterprise Mobility. Certified in most Microsoft technologies and over 23 years as Microsoft Certified Trainer (MCT)

You may also like...

1 Response