powershellscripts/killopenfiles.ps1

9 lines
590 B
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#kill open files in powershell
$sessn = New-CIMSession -Computername $computer
Get-SMBOpenFile -CIMSession $sessn |select ClientUserName,Locks,Path,SessionID,FileID | Out-GridView -PassThru title "Select Open Files"|Close-SmbOpenFile -CIMSession $sessn -Confirm:$true -Verbose
#example for file type
#Get-SMBOpenFile -CIMSession $sessn |Where-Object {$_.Path -Like "*.msg*""} |select ClientUserName,Locks,Path,SessionID,FileID | Out-GridView -PassThru title "Select Open Files"|Close-SmbOpenFile -CIMSession $sessn -Confirm:$true -Verbose
#Where-Object {$_.Path -Like “*.msg*”}