Connecting to remote server xxxx failed with the following error message : The WS-Management service cannot process the request. This user is allowed a maximum number of 18 concurrent shells[Answered]RSS
"Connecting to remote server xxxx failed with the following error message :
The WS-Management service cannot process the request. This user is allowed a maximum number of 18 concurrent shells,
which has been exceeded. Close existing shells or raise the quota for this user.
For more information, see the about_Remote_Troubleshooting Help topic."
The above runtime error caused by a C# codes which was converted from VB codes, the VB codes work fine, but I got the above error after converted the codes to C#.
Member
366 Points
2214 Posts
Connecting to remote server xxxx failed with the following error message : The WS-Management serv...
Mar 11, 2020 01:00 PM|Peter Cong|LINK
"Connecting to remote server xxxx failed with the following error message :
The WS-Management service cannot process the request. This user is allowed a maximum number of 18 concurrent shells,
which has been exceeded. Close existing shells or raise the quota for this user.
For more information, see the about_Remote_Troubleshooting Help topic."
The above runtime error caused by a C# codes which was converted from VB codes, the VB codes work fine, but I got the above error after converted the codes to C#.
Here is the VB Codes:
Dim runspace As Runspace
Dim powershell As PowerShell
…..
runspace = RunspaceFactory.CreateRunspace(connectionInfo)
….
Try
runspace.Open()
powershell = powershell.Create()
...
Finally
'dispose the runspace and enable garbage collection
runspace.Dispose() //
runspace = Nothing //
'Finally dispose the powershell and set all variables to null to free up any resources
powershell.Dispose()
powershell = Nothing
End Try
**********************************************************
This is C# Codes:
Runspace runspace;
PowerShell powershell = null;
…..
try {
runspace.Open();
powershell = PowerShell.Create();
…..
finally {
//dispose the runspace and enable garbage collection
runspace.Dispose();
runspace = Nothing; //this code does not compile at all, but it compiles with the code of runspace = null; are they same?
powershell.Dispose();
powershell = Nothing; //this codes does not compile, but it is OK with powershell = null; are they same?
}
Basically, as the error message says, I need to release runspace to run powershell in C#,
Appreciate any help, much appreciated!
Member
366 Points
2214 Posts
Re: Connecting to remote server xxxx failed with the following error message : The WS-Management...
Mar 11, 2020 05:20 PM|Peter Cong|LINK
The problem is resolved by adding
runspace.Close();