title: running a command on a remote windows using winrm in C#
body: <p>I have a simple way to connect to a remote windows machine from a local windows machine using winrm.
  Here is the powershell code that is working:</p>
  
  <pre><code>Set-Item WSMan:\localhost\Client\TrustedHosts -Value $ip -Force
  $securePassword = ConvertTo-SecureString -AsPlainText -Force 'mypass'
  $cred = New-Object System.Management.Automation.PSCredential 'Administrator', $securePassword
  $cmd = {ls C:\temp}
  Invoke-Command -ComputerName $ip -Credential $cred -ScriptBlock $cmd
  </code></pre>
  
  <p>I want to figure out how to do the exact thing in c#.</p>
  
  <p>Also, it would be additionally helpful if someone tell me whether there is a method to send files in c# winrm.</p>
  
  <p>Note: the is only a c# code needed on my local machine. The remote machine is already setup.</p>