PowerCLI

 View Only
  • 1.  Horizon View API (HV Helper Module) - Run CMDlets against multiple HVServers

    Posted Sep 04, 2017 08:36 AM

    Dear all,

    how do you guys run cmdlets like "get-hvmachinesummary" against multiple connected hvservers?

    If i run the command, stating nothing, it just runs against the last connected hvserver.

    If i try to specify multiple it asks for a certain variable type i was unable to provide so far.

    PS C:\WINDOWS\system32> Get-HVMachineSummary -HvServer $global:DefaultHVServers

    Get-ViewAPIService : Expected hvServer type is ViewServerImpl, but received: [ViewServerInterop[]]

    Thanks for any suggestions



  • 2.  RE: Horizon View API (HV Helper Module) - Run CMDlets against multiple HVServers

    Posted Sep 04, 2017 09:29 AM

    The HVServer parameter doesn't accept an array, just a single HVServer.

    Try like this

    $global:DefaultHVServers | %{

        Get-HVMachineSummary -HvServer $_

    }



  • 3.  RE: Horizon View API (HV Helper Module) - Run CMDlets against multiple HVServers

    Posted Oct 03, 2024 01:16 PM

    Trying to connect multiple pod's connection servers to get the pools specific information of "reuse computer objects" script but unable to connect multiple connection servers. 

    using the below commands but received the error, please assist to Prepare the script.

    $connserver = Get-Content "C:\temp\conservers.txt"

    $credential = Get-Credential

    Connect-HVServer -Server $connserver

    Connect-HVServer -Server $connserver
    cmdlet Get-Credential at command pipeline position 1
    Supply values for the following parameters:
    Connect-HVServer : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Server'. Specified method is not supported.




  • 4.  RE: Horizon View API (HV Helper Module) - Run CMDlets against multiple HVServers

    Posted Oct 04, 2024 03:13 AM

    Same issue, the cmdlet doesn't accept an array, only a single String.
    Run the cmdlet in a loop



    ------------------------------


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


    ------------------------------



  • 5.  RE: Horizon View API (HV Helper Module) - Run CMDlets against multiple HVServers

    Posted Oct 07, 2024 05:04 PM

    Hi LucD,

    I'm new to this scripting, can you please give any sample script which uses the cmdlet in loop. 
    From that i can try to prepare my script.

    Thank you.




  • 6.  RE: Horizon View API (HV Helper Module) - Run CMDlets against multiple HVServers

    Posted Oct 08, 2024 11:14 AM

    When you are connected to all Connection servers, you could do

    foreach($cServer in $global:DefaultHVServers){
       Get-HVMachineSummary -HvServer $cServer
    }


    ------------------------------


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


    ------------------------------



  • 7.  RE: Horizon View API (HV Helper Module) - Run CMDlets against multiple HVServers

    Posted Oct 08, 2024 12:29 PM

    This is the most reliable way to split an array into its single elements:

    ($global:DefaultHVServers).Foreach({Get-HVMachineSummary -HvServer $_})

    You can use it for any CmdLet in pwsh.
    If you use Foreach-Object (which works different from the foreach command) you get 3 parts that can be used.

    BEGIN PROCESS END.
    In the BEGIN part you do some starting command(s) like reading a file that contains servernames.
    In the PROCESS part you getter all info in a loop of command(s) that have to repeat.
    In the END part you work the magic of changing things in to 1 final object, like an output to another cmdlet or a file or the screen.

    For a better understanding look at:
    help foreach -Examples

    If you realy want to learn Powershell search for "Don Jones".




  • 8.  RE: Horizon View API (HV Helper Module) - Run CMDlets against multiple HVServers

    Posted Oct 15, 2024 03:21 PM

    Hi Bart van den Donk,

    Thanks for the input, i will check on that command.