【发布时间】:2019-07-14 21:26:58
【问题描述】:
我的笔记本昨天维修回来了。它的 HDD 被 SSD 替换,全新安装 Windows 10 Home Single Language (Update 1903),没有备份。它还带有一个管理员帐户,称为“用户”。这个细节很烦人。
我本应该拿出更好的研究拳头,但我太不耐烦了。所以,我的第一次尝试是在控制面板上更改用户名。但用户文件夹名称保持不变。然后,我执行了Control UserPasswords2 并在那里更改了用户名。第二次运行它,我看不到任何列出的用户,但我只需要重新启动。我不记得以前的用户名是什么,但到那时显示的是新用户名。但是,同样,文件夹名称没有改变。
我注意到另一个奇怪的事情:我的 Wi-Fi 被复制了。例如,我可以使用“NET”和“NET 2”。这是通过删除两个网络来解决的。以防万一,我检查了 Temp 文件夹是否重复,但实际上没有。
然后,我进行了更长时间的研究,许多地方都指出了一种解决方案,该解决方案需要更改注册表中所有匹配的用户路径值,大约 100 个条目。使用 PowerShell 脚本看起来是个好主意。我没有找到任何代码,但我已经在使用 PowerShell。尝试一些简单的事情。
我认为坚持使用Get- 命令并避免使用Set- 是安全的。但是当我执行以下操作时:
PS C:\Windows\system32> 1, 2, 3 | Get-ItemProperty
输出是:
Diretório: C:\Windows\system32
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 14/07/2019 11:21 8 1
-a---- 14/07/2019 11:10 2 2
Get-ItemProperty : Não é possível localizar o caminho 'C:\Windows\system32\3' porque ele não existe.
No linha:1 caractere:11
+ 1, 2, 3 | Get-ItemProperty
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Windows\system32\3:String) [Get-ItemProperty], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand
我觉得很奇怪,因为有一个表格,其中包含混合了错误消息的信息,就像它确实改变了一些东西一样。
我查看了 System32 文件夹,有两个文件,没有扩展名,分别命名为 1 和 2。这些是今天在该文件夹中创建和修改的唯一文件。并且1 比2 更老。
这是1里面的内容:
3
文件2为空。
即使关闭 PowerShell,文件也会保留在那里。
这是我在最后一次(也是唯一一次)会话中执行的命令的历史记录:
PS C:\Windows\system32> help GetItemProperty
PS C:\Windows\system32> GetChildItem -path HKCU:\ | GetItemProperty
PS C:\Windows\system32> Get-ChildItem -path HKCU:\ | Get-ItemProperty
PS C:\Windows\system32> Get-ChildItem -path HKCU:\
PS C:\Windows\system32> Get-ChildItem -path HKCU:\ | Get-ItemProperty Name
PS C:\Windows\system32> Get-ChildItem -path HKCU:\ | Get-ItemProperty -Name
PS C:\Windows\system32> Get-ChildItem -path HKCU:\ | Get-ItemProperty -Property "Name"
PS C:\Windows\system32> Get-ChildItem -path HKCU:\ | Get-ItemProperty
PS C:\Windows\system32> Get-ChildItem -path HKCU:\
PS C:\Windows\system32> 1,2,3 | Get-ItemProperty
PS C:\Windows\system32> 1, 2, 3 | Where $_ > 2
PS C:\Windows\system32> 1, 2, 3 | Where ($_ > 2)
PS C:\Windows\system32> 1, 2, 3 | Where $PSItem > 2
PS C:\Windows\system32> 1, 2, 3 | Where $_ -eq 2
PS C:\Windows\system32> 1, 2, 3 | Where -($_ > 2)
PS C:\Windows\system32> 1, 2, 3 | Where-Object $_ -eq 2
PS C:\Windows\system32> 1, 2, 3 | Where-Object -$_ -eq 2
PS C:\Windows\system32> 1, 2, 3 | Where -$_ -eq 2
PS C:\Windows\system32> 1, 2, 3 | Where -$_ = 2
PS C:\Windows\system32> 1, 2, 3 | Where -$_ == 2
PS C:\Windows\system32> 1, 2, 3 | Where - $_ -eq 2
PS C:\Windows\system32> 1, 2, 3 | Where -$_ -eq 2
PS C:\Windows\system32> 1, 2, 3 | Where -$_ -greater 2
PS C:\Windows\system32> 1, 2, 3 | Where -$_ -gt 2
PS C:\Windows\system32> 1, 2, 3 | Where -$_ -gt 0
PS C:\Windows\system32> 1, 2, 3 | Where -gt 0
PS C:\Windows\system32> 1, 2, 3 | Where-Object -$ -gt 1
PS C:\Windows\system32> 1, 2, 3 | Where-Object -$_ -gt 1
PS C:\Windows\system32> 1, 2, 3 | Where-Object -gt 1
PS C:\Windows\system32> 1, 2, 3 | Where -Property $_ Value 2
PS C:\Windows\system32> help Where
PS C:\Windows\system32> 1, 2, 3 | Where { $_ > 1 }
PS C:\Windows\system32> 1, 2, 3 | % { $_ > 1 }
PS C:\Windows\system32> 1, 2, 3 | % { $_ > 1 } | Write
PS C:\Windows\system32> 1, 2, 3 | % { $_ > 1 } | Write-Verbose
PS C:\Windows\system32> 1, 2, 3 | Where { $_ -eq 1 }
PS C:\Windows\system32> 1, 2, 3 | Where { $_ -gt 1 }
PS C:\Windows\system32> 1, 2, 3 | % { $_ -gt 1 }
PS C:\Windows\system32> 1, 2, 3 | % { if ($_ -gt 1) { Write $_ } }
PS C:\Windows\system32> help Write
PS C:\Windows\system32> 1, 2, 3 | Get-ItemProperty
我不打算更改注册表,我认为只需恢复旧名称并创建一个单独的帐户就可以了。但是我应该担心这两个文件吗?
抱歉,帖子太长了。提前谢谢你。
【问题讨论】:
标签: powershell windows-10 filenames user-accounts side-effects