Close-SMBOpenFile throws error and isn't caught in try-catch Close-SMBOpenFile throws error and isn't caught in try-catch powershell powershell

Close-SMBOpenFile throws error and isn't caught in try-catch


It looks like we may have narrowed down the root cause due to the Get-SmbOpenFile -FileId $fileId failing. This is probably related to the multiple 4-apart concurrent file listings, such that when, in the last example above, 1065151889485 is closed, it "closes" 1065151889489 as well, and then when we try to iterate on the loop for this value, it can't find it, and thus errors out.

PS Z:\git\devops_powershell> Get-SMBOpenFileFileId        SessionId     Path    ShareRelativePath ClientComputerName   ClientUserName------        ---------     ----    ----------------- ------------------   --------------1065151889485 1065151889409 C:\                       ...SNIP              ...SNIP1065151889489 1065151889409 C:\                       ...SNIP              ...SNIP1065151889613 1065151889409 C:\temp temp              ...SNIP              ...SNIP1065151889617 1065151889409 C:\temp temp              ...SNIP              ...SNIP1065151889833 1065151889409 C:\temp temp              ...SNIP              ...SNIP

I'm going to change that Get-SmbOpenFile -FileId $fileId line in the morning and test with the "error bypass" nonsense and see what happens there too. Or just take that check out and try again.

I'm still very very confused how the try-catch doesn't actively catch the error as thrown. If it did I would just have a Write-Warning instead of the end-process I have now.