I struggled with this one for a while, but did eventually find a solution (or more correctly, a work-around).
Use the Invoke-NcSsh function (requires PS Toolkit 4.5.1, and you'll need to enable SSH access as well as ONTAPI for the account you use)
Here's a function I use to close CIFS sessions from a specified client IP:
Function Close-NtapSessions () {
Param(
[Parameter(Mandatory=$True,Position=0,HelpMessage="IP address of client")]
[string]$ClientIP = ''
)
Write-Output "`Retrieving CIFS sessions for $ClientIP"
$ClientIP = $ClientIP -replace '\s',''
$sessions = Get-NcCifsSession -Query @{Address=$ClientIP} | select "Address","ConnectionId","SessionId", "Node", "Vserver", "ConnectedTime"
$sessions | Format-List | Write-Output
if ($sessions) {
$cluster = (Get-NcCluster).ClusterName
foreach ($session in $sessions ) {
$Vserver = $session.Vserver
$SessionId = $session.SessionId
$ConnectionId = $session.ConnectionId
$node = $session.Node
Write-Output "Running: cifs session close -node $node -session-id $SessionId -connection-id $ConnectionId -vserver $Vserver"
Invoke-NcSsh -Command "cifs session close -node $node -session-id $SessionId -connection-id $ConnectionId -vserver $Vserver"
}
}
else {
Write-Output " No connected sessions found."
}
Write-Output "`nAfter close - Retrieving CIFS sessions for $($ClientIP):"
$sessions = Get-NcCifsSession -Query @{Address=$ClientIP} | select "Address","ConnectionId","SessionId", "Node", "Vserver", "ConnectedTime"
if ($sessions) { $sessions | Format-List }
else {Write-Output " No connected sessions found.`n" }
return ($_)
}
- MIke C