我正在尝试使用用户凭据的答案文件运行 Invoke-Command,但我似乎无法让它完成运行。我使用的是本地管理员帐户,因此域上没有任何内容。这是我所拥有的和错误:
$Username = "$Env:Computername\admin"
$Pass = ConvertTo-SecureString "12345" -AsPlainText -Force
$User = New-Object Management.Automation.PSCredential($UserName, $Pass)
Invoke-Command -ComputerName $Env:Computername -Credential $User -ScriptBlock {
$Path = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System'
$Name = 'DontDisplayLastUserName'
Set-ItemProperty -path $Path -name $Name -value 0
}
和错误:
[computer] Connecting to remote server failed with the following error message : WinRM cannot process the request. The following error occured while using Kerberos authentication: There are curren
tly no logon servers available to service the logon request.
任何帮助是极大的赞赏。
工作解决方案:
$Username = "$Env:Computername\admin"
$Pass = ConvertTo-SecureString "12345" -AsPlainText -Force
$User = New-Object Management.Automation.PSCredential($UserName, $Pass)
Invoke-Command -ComputerName localhost -Credential $User -ScriptBlock {
$Path = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System'
$Name = 'DontDisplayLastUserName'
Set-ItemProperty -path $Path -name $Name -value 0
}