使用 IP 地址作为目标服务器调用命令根本不起作用

使用 IP 地址作为目标服务器调用命令根本不起作用

请参阅以下命令,并且启用受信任的主机后,此操作不起作用:

Invoke-Command -ComputerName <IP address> -port 5985 -Credential (New-Object System.Management.Automation.PSCredential ('Domain\User', (ConvertTo-SecureString 'passwd' -AsPlainText -Force))) -Authentication CredSSP -ScriptBlock {Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010;Get-Mailbox}

当 Computername 是主机名时,此方法有效。IP 地址根本不起作用

答案1

Microsoft 的信息中对此进行了记录: http://technet.microsoft.com/library/hh849719.aspx

本质上,您不能在没有 -credential 参数的情况下将 -computername参数与IP一起使用,但您可以只将 -computername与主机名一起使用。

答案2

如果您不受 PowerShell 命令的约束,只需从 Microsoft 下载 psexec: http://technet.microsoft.com/de-ch/sysinternals/bb897553.aspx

这也适用于旧机器和批处理脚本。

相关内容