I am trying to access EC2 machines remotely to get some info using C#. I wrote code as below:-
ConnectionOptions options = new ConnectionOptions
{
Username = serverspace.ServerIP + @"\xxxxxx",
Password = "xxxxxxx",
Impersonation = ImpersonationLevel.Impersonate,
EnablePrivileges = true
};
ManagementScope scope = new ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", serverspace.ServerIP), options);
scope.Connect();
But an RPC exception is thrown as below:- The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at System.Management.ManagementScope.InitializeGuts(Object o) at System.Management.ManagementScope.Initialize()
1- Is the problem in the code? 2- Do I need to adjust anything in all machines firewall?