The new winserver2016 supports a nano-mode, like the previous core mode, can only be remotely managed, only support x64, only 610M, do not let the CentOS mini version alone.
This nano version, by default only WinRM, so only PowerShell, after installation F11 reset password can be used.
The following is a. NET program way to transfer files remotely.
The premise is that the local and remote PowerShell can be connected. In general, Windows does not turn on PowerShell by default, run Enable-psremoting (administrator) on both sides, and add the target server to the trusted host:
Example: Set-item wsman:\localhost\client\trustedhosts-value 192.160.0.100
The ability to reference System.Management.Automation.dll is required. Generally it appears in many places in the system, I from C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__ 31bf3856ad364e35\system.management.automation.dll
Reference.
static void Main (string[] args) { //Create PS Object var ps = powershell.create (); PS. AddCommand ("new-pssession");//Get a new Session object PS. Addargument ("192.168.0.100");//destination server address var ss = New System.Security.SecureString (); string pwd = "123123";//Administrator Password foreach (var ch in pwd) SS. Appendchar (CH);//Enter char into the secure string in turn Pscredential cred = new Pscredential ("Administrator", ss);//Construct a voucher with a secure string PS. Addparameter ("credential", cred);//Voucher Parameters PSSession session = null; var ret = PS. Invoke ();//execute new-pssession if (PS. Streams.Error.Count > 0)//error { Console.WriteLine (Ps. Streams.error[0]); return; } ELSE &NBsp; session = Ret[0]. Baseobject as pssession; PS. Commands.clear ();//cleanup command, Reuse PS Object PS. AddCommand ("CP");//copy-item PS. Addargument ("c:\\users\\fyter\\ document \ \ Test file. txt");//local file PS. Addparameter ("Destination", "c:\\");//destination computer hard disk location to which the session is connected PS. Addparameter ("Tosession", session);//target session Var result = PS. Invoke ();//execute if (PS. Streams.Error.Count > 0) Console.WriteLine (Ps. Streams.error[0]); }
Using C#+powershell for file transfer between Windows systems