My local computer name is LOCAL-MACHINE, And remote computer name is REMOTE-MACHINE.
I expect issue powershell cmdlets on local computer, through Enter-PSSession connect to remote computer, and excute hostname.exe on pssession of remote computer, then exit.
I issue these command on local computer powershell ISE.
$password = ConvertTo-SecureString "Mypassword" -AsPlainText -Force
$cred=new-object System.Management.Automation.PSCredential("domain\user",$password)
Enter-PSSession -ComputerName REMOTE-MACHINE -Port 5986 -Credential $cred -UseSSL -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck)
hostname.exe
Exit-PSSession
I expect GET resut:
REMOTE-MACHINE
But I get this result(local computer name):
LOCAL-MACHINE
What can I do?
[REMOTE-MACHINE]: PS C:\..
? if not you are not connected... also are you run it all at once? or line by line? – Avshalomhostname.exe
– Mathias R. Jessen