How can i get this to show me who's using the shares on our NETAPP.
$computer = "gozer"
$namespace = "root\CIMV2" # note to self find out if this is correct
$userSessions = Get-WmiObject -class Win32_ServerConnection -computername $computer -namespace $namespace
if($userSessions -ne $null)
{
Write-Host "The following users are connected to your PC: "
foreach ($userSession in $userSessions)
{
$userDetails = [string]::Format("User {0} from machine {1} on share: {2}",
$userSession.UserName, $userSession.ComputerName, $userSession.ShareName)
Write-Host $userDetails
}
Read-Host
}
exit
the error i receive when i run this pointing at a NETAPP SVM is:
Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) At C:\test\whos-using-the-share.ps1:3 char:17 + $userSessions = Get-WmiObject -class Win32_ServerConnection -computername $compu ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand