VMware Cloud Community
MCioe
Enthusiast
Enthusiast
Jump to solution

Connect-VIServer throws Invalid URI error in Powershell Studio, but is fine outside

I'm not sure if this is a Powershell Studio 2014 problem or a PowerCLI problem, but other folks have reported the "Invalid URI: The hostname could not be parsed" error, so I'll start here.

I have a PowerCLI 5.0.1 on Windows 7, Powershell v2.0 and Powershell Studio 2014.

In my script, when I execute the command Connect-VIServer -server $server, the command fails and throws the Invalid URI error.  However, when I run my script in the PowerCLI command window, the script runs fine.

I assume I have an environment problem in Powershell Studio, but am wondering what circumstance causes PowerCLI to throw that error.

So far I have not had much luck with Powershell Studio 2014 and PowerCLI, not sure if it's powershell v2.0 or something else. 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
MCioe
Enthusiast
Enthusiast
Jump to solution

This looks like an environment problem in Powershell Studio.

I have multiple ps1 files and I use dot-sourcing to load the supporting ps1 files which includes the call to connect-VIServer.  When I put the connect-VIServer in the main ps1 file I can connect to my vCenter, but when I put it in the dot-sourced file, I can't connect, nor can does the Test-Connection command work.


Thanks for the help.

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership
Jump to solution

Could this be a name resolution thing in PS Studio ?

How did you specify the vCenter name ? As a hostname, or as a FQDN ?


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

0 Kudos
MCioe
Enthusiast
Enthusiast
Jump to solution


I've tried a few ways, ip address and the hostname, I don't have an FQDN.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

When you do a

Test-Connection -ComputerName vcenter -Count 1

from PowerShell Studio, does that return a valid result ?

Replace 'vcenter' with the name you are using on the Connect-VIServer cmdlet.


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

MCioe
Enthusiast
Enthusiast
Jump to solution

I tried a couple of things.

     I wrote a small test script which works in Powershell Studio, it basically adds the vmware snapins,  t ests the connection and calls connect-viserver with no issues.

     However, in my big script, I get an error on the test-connection call: "Testing connection to computer 'vct' failed: The requested name is valid, but no data of the requested type was found" ....PingException...

So it seems that my big script can't get to vCenter, but the little test script can.  Yuck

0 Kudos
MCioe
Enthusiast
Enthusiast
Jump to solution

This looks like an environment problem in Powershell Studio.

I have multiple ps1 files and I use dot-sourcing to load the supporting ps1 files which includes the call to connect-VIServer.  When I put the connect-VIServer in the main ps1 file I can connect to my vCenter, but when I put it in the dot-sourced file, I can't connect, nor can does the Test-Connection command work.


Thanks for the help.

0 Kudos