I have strange scenario here at server machine. There I setup shared path 'C:\UPD$'
where within deep there is .VHDX file which is accessed by external clients. ( i.e. other client machines have opened them ).
I want to forcefully close the handle which turned out to be closed upon issuing 'Get-SmbOpenFile | Where-Object { $._Path -match 'path1' -and 'filename.vhdx' }'
.
But Immediately, it get's busy again. Then I confirm this behavior by issuing the above command again and it returns me the valid result ( i.e. It has some opened handles )
I have literally no idea why it becomes busy again?
It seems it has certain timeout. I closed the handle , it just closed, after couple of seconds I didn't interact with it and it becomes busy again and returning me non-zero results ( showing exactly that handle is in use ).
Can any body tell me what alternate command should be used to permanently close the disk handle of .VHDX file? Or what is the problem of Get-SmbOpenFile
commandlet? It's really weired behavior. You closed the handle and file becomes busy again ( I even confirmed it that file is not mounted somewhere else on remote server ).
I executed remote command by using Enter-PSSession ( i.e. it is Remote run space execution under specific account ).
Morover, following are the results when I am trying to forcefully close file using Close-SmbOpenFile -Force
, next time Get-SmbOpenFile
returns no result buy still reading the file using stream returns the error that it is being used by another process.
Could any body tell me what's wrong in the above scenario?
Edit
You can see that after forcefully closing the handle by using Get-SmbOpenFile -Force
, Get-SmbOpenFile
is returning 0 results. But file cannot be accessed and mounted by diskmgmt.msc. it says that it is already in use. Why?
Another strange behavior is :
I just tried to launch diskmgmt.msc and tried to attach this file using Action-> 'Attach VHD', it thrown above error ( i.e. file is in use ) and then suddenly issuing Get-SmbOpenFile
started to report certain opened handles as result.
Now idea? Seems timeout issue occuring. Due to certain reasons, time out occurs and then it forgets its' handles information or viceversa.