I am trying to close all of the open files in the shared folders of a server via PowerShell script. I found the following script which only close files on one drive (F:), however, this server has 3 drives (F:\, G:\, H:) which I want to close all.
net files |
where { $_.Contains( "F:\" ) } |
foreach { $_.Split( ' ' )[0] } |
foreach { net file $_ /close }
Is there a way to add missing drives into this script or I have to use the same script separately for each drive?
I tried { $_.Contains( "F:\", "G:\", "H:\" ) }
but didn't work
Thank you for your help!