Quantcast
Channel: Virtual Machine Manager – General forum
Viewing all articles
Browse latest Browse all 4089

SCVMM through powershell command: runspace.Open() failing when Machine IP address is entered

$
0
0

Hi,

I am trying to run Power Shell command using C# to get scvmm data. Please find below code

              

  WSManConnectionInfo connectioninfo = new WSManConnectionInfo(false,
                 "ServerName", 5985, "/wsman", "", new PSCredential("domain\password", secureString));


                connectioninfo.AuthenticationMechanism = AuthenticationMechanism.Default;
                //connectionInfo.ProxyAuthentication = AuthenticationMechanism.Negotiate;
                var runspace = RunspaceFactory.CreateRunspace(connectioninfo);
                runspace.Open();

When I am entering ServerName as machine name, code is working fine.

But when I am entering ServerName as IP address , it throwing below exception

"

Connecting to remote server failed with the following error message : The WinRM client cannot process the request. Default authentication may be used with an IP 

address under the following conditions: the transport is HTTPS or the destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm.cmd to 

configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to set TrustedHosts run the following 

command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic."

In such case we have to configure trustedHosts, but in our case we cant force/ask user to do any settings.

Is there any other way, through which we can do this setting through c#.

Any help in this regard is highly appreciable.



Viewing all articles
Browse latest Browse all 4089

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>