Restart Manager is the component behind the reboot prompt after an install. It can be called from PowerShell and returns the process id and name holding a file.
$sig = '[DllImport("rstrtmgr.dll", CharSet=CharSet.Unicode)] public static extern int RmStartSession(out uint h, int f, string k); [DllImport("rstrtmgr.dll")] public static extern int RmEndSession(uint h); [DllImport("rstrtmgr.dll", CharSet=CharSet.Unicode)] public static extern int RmRegisterResources(uint h, uint n, string[] f, uint a, object b, uint c, object d); [DllImport("rstrtmgr.dll")] public static extern int RmGetList(uint h, out uint n, ref uint na, [In,Out] RM_PROCESS_INFO[] i, ref uint r); public struct RM_PROCESS_INFO { public RM_UNIQUE_PROCESS p; public string s; public string a; public uint t; public uint u; } public struct RM_UNIQUE_PROCESS { public int d; public System.DateTime t; }'
Add-Type -MemberDefinition $sig -Namespace W32 -Name Rm -ErrorAction SilentlyContinue
$key = [guid]::NewGuid().ToString()
$h = 0; [void][W32.Rm]::RmStartSession([ref]$h, 0, $key)
[void][W32.Rm]::RmRegisterResources($h, 1, @('D:\work\report.xlsx'), 0, $null, 0, $null)
$n = 0; $na = 8; $ri = New-Object 'W32.Rm+RM_PROCESS_INFO[]' $na; $r = 0
$rc = [W32.Rm]::RmGetList($h, [ref]$n, [ref]$na, $ri, [ref]$r)
[void][W32.Rm]::RmEndSession($h)
"result $rc, holders $n"; $ri | Where-Object { $_.s } | Select-Object s,a,t