Automation

 View Only
  • 1.  VMware PowerCLI from VB.NET - Linked Mode vCenters

    Posted Mar 23, 2015 06:11 AM

    Hello,


    I have a VB.net desktop application that connects to vCenter servers in linked mode to gather information.

    I'm having an issue with some of the functions I am using, it appears that when running two PowerCLI commands one after the other (in the same subroutine within VB.net but separate commands for PowerCLI) only the first command gathers information for both vCenters...

    I have attached a PDF file which explains my VMware environment arquitecture, and I've provided two examples that show sample code and sample outputs of the functions/cmdlets (test#1 and test#2).  As you can see from the file, only the functions that runs first gathers data from both vCenters, the second one only gathers data from the vCenter that it directly connects to; even though I always use the "-AllLinked" parameter.

    Thanks!



  • 2.  RE: VMware PowerCLI from VB.NET - Linked Mode vCenters

    Posted Mar 23, 2015 06:21 AM

    Any error messages ?

    Can you try to leave out the ErrorAction parameter and check if you get messages ?

    Can you do a Get-PowerCLIConfiguration in the scripts, just to check what is set for DefaultVIServerMode ?

    Do these scripts show the same behavior when you execute them directly from the PowerCLI prompt, and not from a VB script ?



  • 3.  RE: VMware PowerCLI from VB.NET - Linked Mode vCenters

    Posted Mar 23, 2015 07:27 AM

    1. In TEST #2 , the second command is "Get-Datacenter | Select Name" instead of "Get-VM -Location Bogota | Select Name"


    2.DefaultVIServerMode set to single and i get warning message about it .


    3.these scripts show the same behavior when I execute them directly from the PowerCLI prompt


    4.I added this command "Set-PowerCLIConfiguration -DefaultVIServerMode:Multiple -scope session -confirm:$false" and now it running correctly.



  • 4.  RE: VMware PowerCLI from VB.NET - Linked Mode vCenters

    Posted Mar 23, 2015 07:30 AM

    Your DefaultVIServerMode is set to single it seems, you will have to change it permanently.

    Make sure you do that for all scopes.



  • 5.  RE: VMware PowerCLI from VB.NET - Linked Mode vCenters

    Posted Mar 23, 2015 07:34 AM

    If I'll run the command as administrator for all scopes , will it be permanent?



  • 6.  RE: VMware PowerCLI from VB.NET - Linked Mode vCenters

    Posted Mar 23, 2015 07:46 AM

    You need an account that can change the file %ProgramData%\VMware\PowerCLI\PowerCLI_Settings.xml.

    Make sure to do this for all scopes.

    Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Scope AllUsers,User,Session -Confirm:$false



  • 7.  RE: VMware PowerCLI from VB.NET - Linked Mode vCenters

    Posted Mar 23, 2015 03:18 PM

    From the PowerCLI command the functions in the different test scenarios run well,

    But when I run it from within vb.net it only returns values for the vCenter I am using in the connection string.



  • 8.  RE: VMware PowerCLI from VB.NET - Linked Mode vCenters

    Posted Mar 23, 2015 06:05 PM

    Could it be that the environment, which is normally done through the PowerCLI start, is not complete.

    Do you have for example the global variable $global:defaultviservers ?

    I suspect the PowerCLI cmdlets might be looking at that to find all the connections.



  • 9.  RE: VMware PowerCLI from VB.NET - Linked Mode vCenters

    Posted Mar 23, 2015 07:57 PM

    global variable  $global:defaultviservers and $global:defaultviserver returns null

    When I try to disconnect between the two of scripts I get the following error :

    You have modified the global:DefaultVIServer and global:DefaultVIServers system variables. This is not allowed. Please reset them to $null and reconnect to the vSphere server



  • 10.  RE: VMware PowerCLI from VB.NET - Linked Mode vCenters

    Posted Mar 23, 2015 08:27 PM

    These variables should not be $null after you have done one or more Connect-VIServer