VMware Cloud Community
PiTRe44
Contributor
Contributor

Connect-viserver time-out

Hello all,

I'm searching how to handle time-out while doing a connect-viserver.

I was running some script on a bunch of VC and one of them was in a undefined state. Pinging the server was ok, when connecting, I received the Certificate warning but after that, nothing more.

If I try to connect through VI Client, I received an error message after a while saying "Unable to connect". But, when issuing a connect-viserver cmdlet, the script just keeps on waiting (I launched it yesterday before leaving and it has has wait from 10PM to 9AM when I check out ...)

Is there a way to handle this kind of case ? To force a time-out value to hang up with the connection ?

thanks for your help.

Tags (1)
0 Kudos
7 Replies
LucD
Leadership
Leadership

This doesn't really answer your question but you could check if the VC is available and answering.

I tend to do this with a try to get to the MOB.

Something like this:

$url = "https://<VC-server>/mob"
$webReq = [http://system.net.WebRequest|http://system.net.WebRequest]::Create($url)
$webReq.Timeout = 600
$webReq.Credentials = New-Object System.Net.NetworkCredential -argumentList (<user>, <password>);
$webReq.Credentials.Domain = <domain>
$webResp = $webReq.GetResponse()

You can test the $webResp variable to see if you got a reply from the VC.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

PiTRe44
Contributor
Contributor

Thanks for your answer, I'll add a new test function before doing my connect-viserver.

By the way, if someone from Vmware reads it, it could be a good idea to add a time-out.

Thanks

0 Kudos
LucD
Leadership
Leadership

Just noticed the forum SW changed part of the script.

It seems to have problems with square brackets.

The script is attached


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
PiTRe44
Contributor
Contributor

Thanks for the script, it will be helpfull.

0 Kudos
PiTRe44
Contributor
Contributor

Hello,

I have try to get it working but I still get this error :

Exception calling "GetResponse" with "0" argument(s): "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."

Any idea ? It seems the problem might be related to the certificate warning of the VC.

Thanks

0 Kudos
LucD
Leadership
Leadership

Did you try the certificate solution in ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
PiTRe44
Contributor
Contributor

Hello,

One more time, thanks for your answer.

But the certificate error output discussed in the thread you mentioned is the one displayed when issuing get-viserver cmdlet. My problem is with the HTTPS request. Yes, I agree, having real certificates on my VC will solve the problem but ... I got on thousand VC, I'm not going to issue as much certificates !

I've done some google search about it, seems there is no solution with Powershell v1.

Thanks for your help.

0 Kudos