2023-10-12 02:22:15 +00:00
|
|
|
#Function to force an upgrade of Store Apps
|
|
|
|
|
2023-10-17 20:35:36 +00:00
|
|
|
Function Update-StoreApps {
|
2023-10-12 02:22:15 +00:00
|
|
|
|
2023-10-12 17:42:01 +00:00
|
|
|
$force_string = "-> Forcing an upgrade of Store Apps (this can take a minute)..."
|
|
|
|
$fail_string = "-> ...something went wrong!"
|
|
|
|
|
2023-10-12 02:22:15 +00:00
|
|
|
#If not WSB or Server, upgrade Microsoft Store Apps!
|
|
|
|
if (!(Test-Path "${env:SystemDrive}\Users\WDAGUtilityAccount") -and (Get-CimInstance Win32_OperatingSystem).Caption -notmatch "Windows Server") {
|
2023-10-17 20:35:36 +00:00
|
|
|
|
|
|
|
Write-ToLog $force_string "yellow"
|
|
|
|
|
2023-10-12 02:22:15 +00:00
|
|
|
try {
|
2023-10-20 07:34:25 +00:00
|
|
|
# Can't get it done with Get-CimInstance, using deprecated Get-WmiObject
|
2023-10-12 02:22:15 +00:00
|
|
|
$namespaceName = "root\cimv2\mdm\dmmap"
|
|
|
|
$className = "MDM_EnterpriseModernAppManagement_AppManagement01"
|
|
|
|
$wmiObj = Get-WmiObject -Namespace $namespaceName -Class $className
|
|
|
|
$wmiObj.UpdateScanMethod() | Out-Null
|
|
|
|
return $true
|
|
|
|
}
|
|
|
|
catch {
|
2023-10-17 20:35:36 +00:00
|
|
|
Write-ToLog $fail_string "red"
|
2023-10-12 02:22:15 +00:00
|
|
|
return $false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|