Microsoft Store Applications
PowerShell script to silently update Microsoft Store applications.
Overview
This script allows you to set Microsoft Store applications to update automatically and also initiates on-demand update scans.
Prerequisites: This script has no prerequisites.
Script
https://github.com/wise-io/scripts/blob/main/scripts/UpdateMicrosoftStoreApps.ps1
<#
.SYNOPSIS
Triggers a Microsoft Store update scan.
.PARAMETER AutoUpdate
Enables automatic Microsoft Store updates.
.EXAMPLE
UpdateMicrosoftStoreApps.ps1 -AutoUpdate
#>
param ([switch]$AutoUpdate)
if ($AutoUpdate) {
try {
$RegPath = 'HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore'
if (!(Test-Path $RegPath)) { New-Item -Path $RegPath -Force | Out-Null }
New-ItemProperty -Path $RegPath -Name 'AutoDownload' -Value 4 -PropertyType DWORD -Force | Out-Null
Write-Output "`nAutomatic Microsoft Store updates enabled."
}
catch { Write-Warning 'Automatic updates were not enabled.' }
}
try {
$AppUpdateResult = Get-CimInstance -Namespace 'Root\cimv2\mdm\dmmap' -ClassName 'MDM_EnterpriseModernAppManagement_AppManagement01' | Invoke-CimMethod -MethodName UpdateScanMethod
if ($AppUpdateResult.ReturnValue -ne 0) { $AppUpdateResult }
else { Write-Output 'Starting Microsoft Store update scan...' }
}
catch {
Write-Warning 'Unable to start Microsoft Store update scan.'
Write-Warning $_
exit 1
}
Examples
Example 1
.\UpdateMicrosoftStoreApps.ps1
This example initiates a scan for Microsoft Store application updates and applies them.
Example 2
.\UpdateMicrosoftStoreApps.ps1 -AutoUpdate
This example enables automatic updates for Microsoft Store applications. It then initiates a scan for updates and applies them.
Parameters
-AutoUpdate
Optional switch parameter that enables automatic updates for Microsoft Store applications.
Last updated
Was this helpful?