Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用powershell测试用户登录_Powershell_Powershell 4.0 - Fatal编程技术网

使用powershell测试用户登录

使用powershell测试用户登录,powershell,powershell-4.0,Powershell,Powershell 4.0,我正在使用powershell上的脚本测试其他地方远程服务器上的用户登录,但我遇到了一个错误。 我使用的代码是 Get-WmiObject -Class win32_account -ComputerName $ComputerName 我得到的错误是: gwmi : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) At line:21 char:21 + $logon_sessions = @(g

我正在使用powershell上的脚本测试其他地方远程服务器上的用户登录,但我遇到了一个错误。 我使用的代码是

Get-WmiObject -Class win32_account -ComputerName $ComputerName
我得到的错误是:

gwmi : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
At line:21 char:21
+ $logon_sessions = @(gwmi win32_logonsession -ComputerName $computername)
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo      : NotSpecified: (:) [Get-WmiObject], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

有人能帮我一下吗。

你到底想测试哪些登录?我正在测试,以确保在服务器上进行更新后用户仍然可用