1

Please see the following command and with Trusted Hosts enabled, this does not work:

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}

This works well when Computername is a hostname. The IP address does not works at all

3
  • Can you post the exact commands you try, and what error you're getting?
    – Trondh
    Oct 11, 2013 at 10:36
  • Could you post the contents of WSMan:\localhost\Client\TrustedHosts - sanitized of course? Oct 11, 2013 at 14:47
  • Because Kerberos.
    – Ryan Ries
    Sep 28, 2015 at 2:47

2 Answers 2

2

This is documented in Microsofts information here: http://technet.microsoft.com/library/hh849719.aspx

Essentially you can not use the -computername parameter with an IP without the -credential parameter as well while you can use just the -computername with a hostname.

0

If you're not bound to PowerShell only commands, just download psexec from Microsoft here: http://technet.microsoft.com/de-ch/sysinternals/bb897553.aspx

This also works for older machines and for batch scripting.

2
  • 2
    PSExec has serious security vulnerabilities and should not be used in an enterprise environment, or anywhere for that matter. This was known in 2013.
    – Colyn1337
    Mar 17, 2021 at 22:42
  • You're right about that, thanks for mentioning it.
    – 768kb
    Aug 1, 2021 at 13:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .