Need help with Powershell commands for CIFS Sessions

I was trying to script to list all the open CIFS connections along with the Complete File path that is open to identify the share the user is connected to, then I could filter the share I’m interested in and disconnect all the sessions related to that share.


I couldn’t find a Get command that can give this information, For Ex:




  • Get-NcCifsSessionFile – gives the file name but not the entire path.
  • Get-NcCifsSession – gives the ConnectionId but not the path.


I remember you mentioned about doing this completely using Powershell, would you be able to help identify the commands for below:


  • Get the list of Files (along with their Share Paths) that have an ongoing session along with Connection ID.
  • Use the Connection ID to kill the session of the user.


Thanks for your help in advance.

Re: Need help with Powershell commands for CIFS Sessions

Hello @MAHESH1111111,


The share name is a property of the object returned by Get-NcCifsSessionFile.  You can see the full path using this snippet:


Get-NcCifsSessionFile | Select SessionId,Vserver,Share,Path

If you want a bit more thorough output, you could do something like this:


Get-NcCifsSessionFile | %{
    $session = Get-NcCifsSession -SessionId $_.SessionId

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


Hope that helps.



If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Re: Need help with Powershell commands for CIFS Sessions

Thanks so much Andrew - updated your command to come up with below:


Get-NcCifsSessionFile | Select SessionId,Vserver,Share,Path,ConnectionId,HostingVolume,Node | Select-String -Pattern <ShareName> | Get-Unique


Close-NcCifsSession -ConnectionId <ConnectionId> -Node <Node> -VserverContext <DataVserver> -Confirm:$false -SessionId <SessionId>


Above two commands will give the list of open files and sessions for a particular share and the details we get from that command can then be scripted to dosconnect the same session.