Skip to content

Commit

Permalink
Catch a rogues exception
Browse files Browse the repository at this point in the history
- Showed up in AppVeyor, but never on my dev machine.
  • Loading branch information
VertigoRay committed Jul 22, 2018
1 parent 2276119 commit 077f26c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion QuserObject/Private/Invoke-Quser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ function Invoke-Quser {
$quser = if ($Server) { '{0} /SERVER:{1}' -f (Get-Command 'quser').Path, $Server } else { (Get-Command 'quser').Path }
Write-Debug "[QuserObject Invoke-Quser] QUSER Command: ${quser}"

$result = (Invoke-Expression $quser) 2>&1
try {
$result = (Invoke-Expression $quser) 2>&1
} catch {
$result = $Error[0].Exception.Message
}
Write-Verbose "[QuserObject Invoke-Quser] QUSER Result (${LASTEXITCODE}):`n$($result | Out-String)"

if ($LASTEXITCODE -eq 0) {
Expand Down

0 comments on commit 077f26c

Please sign in to comment.