OpenRemoteBaseKey尝试执行未经授权的操作

时间:2019-11-21 09:47:34

标签: powershell powershell-remoting

我正在学习Powershell,我正在在线关注此博客,该博客允许访问远程计算机上已安装的软件。同时跟随代码。我收到此错误,但我在网上找不到任何答案。希望有人可以提供帮助。我真的很感激。


Exception calling "OpenRemoteBaseKey" with "2" argument(s): "Attempted to perform an unauthorized operation."
At line:4 char:1
+ $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($type, $Sr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : UnauthorizedAccessException

You cannot call a method on a null-valued expression.
At line:5 char:1
+ $regKey.OpenSubKey($key)
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull


到目前为止,这是我的代码;

$srv = 'testpc01'
$key = "SOFTWARE\Microsoft\Windows\CurrentVersion"
$type = [Microsoft.Win32.RegistryHive]::LocalMachine
$regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($type, $Srv)
$regKey.OpenSubKey($key)


谢谢!

0 个答案:

没有答案
相关问题