Community maintenance is complete. Thank you for your patience!

ONTAP Discussions

Needs Help for CIFS open files in PowerShell


Hello Everyone, 

I am trying to create a script file to get a list of CIFS open file through the PowerShell tool and the main reason of creating this script is our helpdesk team wants to see who left a file open and ask him to close it. We don't wanna use the MMC feature since it provides some unwanted access for helpdesk team. 

I am using the following context and it's working but it generates an output of all SVMs and I wanna be more specific . So, I like to provide an ability for helpdesk team to input a desire SVM name or  Windows User or path. this file will be exported to a csv file to facilitate searching purpose.

Connect-NcController "Controller Name"
Get-NcCifsSessionFile | %{
$session = Get-NcCifsSession -SessionId $_.SessionId

$data = "" | Select "WindowsUser", "SVM", "Path"
$data.WindowsUser = $session.WindowsUser
$data.SVM = $_.Vserver
#$data.SVM =
$data.Path = "\\$($session.LifAddress)\$($_.Share)\$($_.Path)"

}  | Export-Csv -Path "c:\cifs.csv"  -UseCulture -NoTypeInformation




For filtering by a specific SVM, you could use Read-Host to accept input from the person running the script, store it as a variable, and then use the variable in the -Vserver parameter of the Get-NcCifsSessionFile cmdlet. 

For user/path, there isn't a cmdlet parameter that will accept those values, but you could collect the data using Get-NcCifsSession like you have in your code now, and then filter by user/path by piping Get-NcCifsSession to Where-Object to only show relevant data. 


Hi Donny_Lang,


Unfortunately, we're only getting back a shorted output of the open files using Get-NcCifsSession - over the last run there were just about 4 thousand out of a total of 57 thousand.

Do you have (or anyone has) any idea what could be the reason for this and how we might get the problem solved?


Thanks and regards

NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner