I'm very new to PS, so I think I'm missing something basic here. I can make a remote powershell session like this ...
$Session = New-PSSession -ConfigurationName Microsoft.Exchange
-ConnectionUri https:
-Credential "Domain\Admin"
I need an equivalent in C #, so I'm trying to do this, but it doesn't work ...
WSManConnectionInfo connInfo = new WSManConnectionInfo(
new Uri("https://remote.com/Powershell"),
"/wtf",
cred);
using (Runspace runspace = RunspaceFactory.CreateRunspace(connInfo))
{
runspace.Open();
using (PowerShell ps = PowerShell.Create())
{
ps.Runspace = runspace;
}
}
This is not with ...
System.Management.Automation.Remoting.PSRemotingTransportException was unhandled
Message=Connecting to remote server failed with the following error message : The WS-Management service cannot process the request. The resource URI (/wsman) was not found in the WS-Management catalog....
How can I translate this to C #? What is the "shellUri" parameter and how to pass the configuration name (Microsoft.Exchange in my case)?
source
share