Skip to content

Commit

Permalink
Merge pull request Romanitho#444 from KnifMelti/minor
Browse files Browse the repository at this point in the history
Store Apps info corrected
  • Loading branch information
Romanitho authored Oct 23, 2023
2 parents b562306 + fdc67e0 commit 3664c5b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Winget-AutoUpdate/functions/Update-StoreApps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

Function Update-StoreApps {

$force_string = "-> Forcing an upgrade of Store Apps (this can take a minute)..."
$info_string = "-> Forcing an upgrade of Store Apps..."
$action_string = "-> ...this can take a minute!"
$fail_string = "-> ...something went wrong!"
$notrelevant_string = "-> WAU is running on a WSB (Windows Sandbox) or a Windows Server - Microsoft Store is not available!"
$irrelevant_string = "-> ...WAU is running on WSB (Windows Sandbox) or Windows Server - Microsoft Store is not available!"

Write-ToLog $info_string "yellow"

#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") {

Write-ToLog $force_string "yellow"

try {
# Can't get it done with Get-CimInstance, using deprecated Get-WmiObject
$namespaceName = "root\cimv2\mdm\dmmap"
$className = "MDM_EnterpriseModernAppManagement_AppManagement01"
$wmiObj = Get-WmiObject -Namespace $namespaceName -Class $className
Write-ToLog $action_string "green"
$wmiObj.UpdateScanMethod() | Out-Null
return $true
}
Expand All @@ -25,6 +27,6 @@ Function Update-StoreApps {
}
}
else {
Write-ToLog $notrelevant_string "yellow"
Write-ToLog $irrelevant_string "yellow"
}
}

0 comments on commit 3664c5b

Please sign in to comment.