Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.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
无法将HKU注册表配置单元映射到powershell_Powershell_Registry - Fatal编程技术网

无法将HKU注册表配置单元映射到powershell

无法将HKU注册表配置单元映射到powershell,powershell,registry,Powershell,Registry,我有一个关于从注册表项HKU(HKEY_用户)中删除的问题。如果使用powershell运行此操作,则会出现错误: Invoke-Command -ComputerName $inputPC -ScriptBlock { Remove-Item -Path 'HKU:\S-1-5-25\Software\Microsoft\Windows\CurrentVersion\RunOnce'} 错误: Cannot find drive. A drive with the name 'HKU' do

我有一个关于从注册表项HKU(HKEY_用户)中删除的问题。如果使用powershell运行此操作,则会出现错误:

Invoke-Command -ComputerName $inputPC -ScriptBlock { Remove-Item -Path 'HKU:\S-1-5-25\Software\Microsoft\Windows\CurrentVersion\RunOnce'}
错误:

Cannot find drive. A drive with the name 'HKU' does not exist.
    + CategoryInfo          : ObjectNotFound: (HKU:String) [Remove-Item], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
    + PSComputerName        : clt64792

但是如果对于
HKU:
我将其交换到
HKLM:
中,它可以工作并删除注册表项,我如何访问
HKU
?我尝试了不同的方法来删除注册表项,所有方法都是相同的,但没有一种方法映射HKU注册表项。

默认情况下,仅定义了以下引用注册表位置的PowerShell驱动器:

PS>获取PSDrive-PSProvider注册表
名称已用(GB)免费(GB)提供程序根CurrentLocation
----           ---------     --------- --------      ----                                                                                                           ---------------
HKCU注册表HKEY_当前用户
HKLM注册表HKEY_本地_计算机
也就是说,默认情况下仅存在驱动器
HKCU:
HKLM:


要访问“HKEY_用户”配置单元中的密钥,您有两个选项:

  • 定义自定义
    HKU
    PowerShell驱动器
    ,如注释所示,尽管这可能不值得(在您的情况下,您必须在传递给
    Invoke命令的脚本块中执行此操作):
  • 将提供程序前缀
    注册表::
    与本机注册表路径一起使用
    ,这对于临时使用来说比较简单
在命令的上下文中:

Invoke命令-ComputerName$inputPC-ScriptBlock{
删除注册表项::HKEY_USERS\S-1-5-25\Software\Microsoft\Windows\CurrentVersion\RunOnce
}

Thre在PowerShell中没有默认设置的HKU驱动器。尝试在脚本块中添加:New PSDrive-PSProvider Registry-Name HKU-Root HKEY_USERSHave尝试过,也找不到它。它在这里工作正常。很明显,但是,您真的在远程会话中创建了驱动器吗?ie.$testing=Invoke命令-ComputerName$inputPC-ScriptBlock{New PSDrive-PSProvider Registry-Name HKU-Root HKEY_用户;获取项目HKU:\S-1-5-25}
# Define drive HKU:
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
# Now you can use HKU:\... paths
# E.g.
Get-ChildItem registry::HKEY_USERS\.DEFAULT