0
我試圖添加一個路徑到PowerShell的註冊表添加/刪除部分,但獲取身份驗證錯誤。如果我使用憑據,它告訴我不要。如果我不這樣做,我會被拒絕。嘗試在Windows 10中添加卸載註冊表路徑與Powershell的憑據
該帳戶是本地帳戶,未連接到AD域。
我有以下腳本:
$cred = Get-Credential
write-host "DEBUG: Without credentials"
New-Item HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Test_App -Force
write-host "DEBUG: With -Credential"
New-Item HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Test_App -Force -Credential $cred
它產生在Windows 10以下錯誤:
Supply values for the following parameters:
Credential
DEBUG: Without credentials
New-Item : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Test_App' is denied.
At Z:\test.ps1:4 char:1
+ New-Item HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Te ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (HKEY_LOCAL_MACH...nstall\Test_App:String) [New-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.NewItemcommand
DEBUG: With -Credential
The provider does not support the use of credentials. Perform the operation again without specifying credentials.
At Z:\test.ps1:7 char:1
+ New-Item HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Te ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotImplemented: (:) [], PSNotSupportedException
+ FullyQualifiedErrorId : NotSupported
建議這是整個Windows Vista中的便攜式通過Windows 10最感激:)