Functions/Start-MicrosoftStoreUpdate.ps1
# Same as click on the button "Get Updates" of the Microsoft Store. function Start-MicrosoftStoreUpdate { $isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") if ($isAdmin -ne $true) { Write-Output "Please run this script with admin privileges." Break } else { Write-Output "Starting Microsoft Store Update..." $result = Get-CimInstance -Namespace "Root\cimv2\mdm\dmmap" -ClassName "MDM_EnterpriseModernAppManagement_AppManagement01" | Invoke-CimMethod -MethodName UpdateScanMethod if ($result.ReturnValue -eq 0) { Write-Output "Microsoft Store Update has ended successfully." } else { Write-Output "An error occurred while starting the Microsoft Store Update. Error code: $($result.ReturnValue)" } } } |