我怎样才能让这个告诉我谁在使用我们的 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
当我运行这个指向 NETAPP SVM 时收到的错误是:
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