我已经创建了 powershell 脚本来显示远程机器上的任务计划。
$User = "<domain-name>\<user-name>"
$PWord = ConvertTo-SecureString -String "<domain-password>" -AsPlainText -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
$cimsession = New-CimSession -ComputerName <member-machine-name> -Credential $Credential -Authentication Negotiate
Get-ScheduledTask -TaskPath "\UpdateTasks\*" -CimSession $cimsession
我得到的输出为
New-CimSession : The client cannot connect to the destination specified in the request. Verify that the
service on the destination is running and is accepting requests. Consult the logs and documentation for the
WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM
service, run the following command on the destination to analyze and configure the WinRM service: "winrm
quickconfig".
At line:5 char:15
+ ... imsession = New-CimSession -ComputerName <member-machine-name> -Credential $Cre ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ConnectionError: (:) [New-CimSession], CimException
+ FullyQualifiedErrorId : HRESULT 0x80338012,Microsoft.Management.Infrastructure.CimCmdlets.NewCimSession
Command
+ PSComputerName : <member-machine-name>
我已经使用 winrm quickconfig 检查并更改了成员机器中的 winrm,最终得到了结果
WinRM service is already running on this machine.
WinRM is already set up for remote management on this computer.
有人能帮我解决这个问题吗?我做错了什么?需要配置任何设置吗?