Skip to content

Instantly share code, notes, and snippets.

@ztrhgf
Last active May 7, 2024 08:08
Show Gist options
  • Save ztrhgf/18f1c32220764f79af3da52d9f47d266 to your computer and use it in GitHub Desktop.
Save ztrhgf/18f1c32220764f79af3da52d9f47d266 to your computer and use it in GitHub Desktop.
function for getting Intune Win32App GRS hash from Intune log file
function _getAppGRSHash {
param (
[Parameter(Mandatory = $true)]
[string] $appId
)
$intuneLogList = Get-ChildItem -Path "$env:ProgramData\Microsoft\IntuneManagementExtension\Logs" -Filter "IntuneManagementExtension*.log" -File | sort LastWriteTime -Descending | select -ExpandProperty FullName
if (!$intuneLogList) {
Write-Error "Unable to find any Intune log files. Redeploy will probably not work as expected."
return
}
foreach ($intuneLog in $intuneLogList) {
$appMatch = Select-String -Path $intuneLog -Pattern "\[Win32App\] ExecManager: processing targeted app .+ id='$appId'" -Context 0, 2
if ($appMatch) {
foreach ($match in $appMatch) {
$hash = ([regex]"\d+:Hash = ([^]]+)\]").Matches($match).captures.groups[1].value
if ($hash) {
return $hash
}
}
}
}
Write-Error "Unable to find App '$appId' GRS hash in any of the Intune log files. Redeploy will probably not work as expected"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment