I have two machines say Machine-A: An azure vm role on cloud. Machine-B: A machine on my network domain.
I can remote login to both MachineA and MachineB (using RDP) and copy say a folder 'temp' from location \MachineA.cloudapp.net\C$\temp to \MachineB\C$\
How do I achieve this programmatically, preferrably through powershell script?
I tried:
$rm = new-object RemoteMachine
$pass = ConvertTo-SecureString -AsPlainText $rm.Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $rm.Username,$pass
Invoke-Command -ComputerName $rm.MachineName -Credential $Cred -ScriptBlock{
# Copy folder
}
Where RemoteMachine is:
public class RemoteMachine
{
public string MachineName="MachineA.cloudapp.net";
public string Username="remote";
public string Password="password";
}
}
It fails with logon failure, though I use the same credentials for RDP. I have another doubt, even if the login is possible, then how will MachineA will know about MachineB?
Probably I am missing something simple and direct!