我试图使用的机器不是域join(不会),并希望能够远程重新启动一个虚拟机(pfSense)与PowerShell脚本。
我不断收到此错误尝试testing我的连接到服务器。
PS C:\WINDOWS\system32> Get-VM –computername 'LAB1' | Where { $_.State –eq 'Running' } Get-VM : The operation on computer 'LAB1' failed: The WinRM client cannot process the request. If the authentication scheme is different from Kerberos, or if the client computer is not joined to a domain, then HTTPS transport must be used or the destination machine must be added to the TrustedHosts configuration setting. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. You can get more information about that by running the following command: winrm help config.
我试过这个:
winrm set winrm/config/client '@{TrustedHosts="DESKTOP-K2GD11M"}' Enable-PSRemoting -Force
但仍然得到错误。
我也检查了get-item wsman:\localhost\Client\TrustedHosts并添加了主机名或计算机名称。
尝试以下从您的域计算机:(这不使用使用Powershell远程处理)
$cred = Get-Credential \LAB1\Username Get-VM -Computername LAB1 -Credential $cred | Where { $_.State –eq 'Running' }
其中用户名是在工作组框中具有访问权限的帐户,而LAB1是工作组框。
您将看到一个对话框,提示您inputLAB1 \ Username的密码
现在,你需要做的是让你的客户机(域)信任服务器(工作组)。
你也可以使用
winrm set winrm/config/client '@{TrustedHosts="LAB1"}'
要么
set-item wsman:\localhost\Client\TrustedHosts -value LAB1 -concatenate
在你的台式机上。
然后在testing时,确保您已包含可在目标服务器上访问的凭据:
$cred = Get-Credential \LAB1\Username Get-VM –Computername 'LAB1' -Credential $cred | Where { $_.State –eq 'Running' }