none
Cluster details script gives error RRS feed

  • Question

  • Hi,

    I have a script which collect cluster details of a list of VM's, the script works fine when I run this from hypervisor where the list of VM exist! But if I am running from a different HV's the script give below error:

    Get-VM : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
    At C:\Users\sipra\Desktop\Clusterdetailsof VM.ps1:10 char:40
    + "{0},{1}" -f $vm, (Get-Cluster (Get-VM $vm).ComputerName)
    +                                        ~~~
        + CategoryInfo          : InvalidData: (:) [Get-VM], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.HyperV.PowerShell.Commands.GetVMCommand

    But I am looking for a script which can be run from any Hyperviosr and should collect the cluster details of the list of server/VMs which resides on other HV's/Cluster as well.

    Can anyone help me here with that ?

    Current Script Below

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

    $output = ForEach ($VM in Get-Content C:\Temp\servers.txt)
    {
    "{0},{1}" -f $vm, (Get-Cluster (Get-VM $vm).ComputerName)     
    }
    echo $output | Out-File C:\Temp\ClusterDetails.txt

    • Moved by Bill_Stewart Friday, January 26, 2018 3:34 PM This is not "teach me PowerShell basics step by step" forum
    Friday, December 15, 2017 4:01 PM