gpt4 book ai didi

powershell - 使用Powershell从值获取完整的注册表项路径

转载 作者:行者123 更新时间:2023-12-02 23:20:28 25 4
gpt4 key购买 nike

因此,我知道我在寻找什么值(value),但我不知道该值(value)的完整途径,因为
"HKLM\software\microsoft\windows nt\currentversion\profilelist",那么用户/个人资料ID?

因此,可以说我接受了一个名为“computer_user_01” 的用户。这意味着他的“ProfileImagePath” "C:\users\computer_user_01"

因此,可以说该值的完整路径为:

`HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-21-3548956479-1181130828-1993911463-1001\ProfileImagePath\C:\users\computer_user_01".

所以我需要 S-1-5-21-3548956479-1181130828-1993911463-1001\

如何从ProfileImagePath键 C:\Users\computer_user_01值获取它?

现在,我可以查询ProfileImagePath键,但是它给了我所有用户:
Get-ItemProperty -Path "hklm:\software\microsoft\windows nt\currentversion\profilelist\*\" -Name "ProfileImagePath" 

我如何进一步指定它,可以这样说:
Get-ItemProperty -Path "hklm:\software\microsoft\windows nt\currentversion\profilelist\*\" -Name "ProfileImagePath" -Value "C:\users\computer_user_01" 

希望你能理解。

最佳答案

您可以尝试以下方法:

# First I get the SID    
$sid = (gwmi win32_useraccount | ? {$_.name -eq "computer_user_01"}).SID
# Then the value of the property you look for
(Get-ItemPropertyValue "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$sid\" -Name "ProfileImagePath")

关于powershell - 使用Powershell从值获取完整的注册表项路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52115063/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com