Automation

 View Only
  • 1.  Modify the existing script.

    Posted Feb 08, 2013 10:52 AM

    $vCenter = Read-host -prompt "Enter the vCenter hostname"
    connect-viserver -server $vCenter -Credential (Get-Credential)
    $cluster=read-host -prompt "Enter the cluster Name"
    $naa.id=read-host -prompt "Enter the naa id"
    Get-cluster -Name "$cluster" | Get-VMHost | Get-ScsiLun -canonicalName "$naa.id" | Set-ScsiLun -MultipathPolicy "roundrobin"

    =============================================

    In the above script is used to change the datastore Multipath policy to RoundRobin. When we execute the script it prompts for vCenter FQDN,credentials,Cluster Name and naa.id of the datastore.

    But i get the below error message.

    =============================================================

    Property 'id' cannot be found on this object; make sure it exists and is settab
    le.
    At C:\users\cz3m7g\desktop\RR.ps1:4 char:6
    + $naa. <<<< id=read-host -prompt "Enter the naa id"
        + CategoryInfo          : InvalidOperation: (id:String) [], RuntimeExcepti
       on
        + FullyQualifiedErrorId : PropertyNotFound

    Get-ScsiLun : 2/8/2013 2:41:48 AM    Get-ScsiLun        Could not find ScsiLunI
    nterop with CanonicalName '.id'.
    At C:\users\cz3m7g\desktop\RR.ps1:5 char:56
    + Get-cluster -Name "$cluster" | Get-VMHost | Get-ScsiLun <<<<  -canonicalName
    "$naa.id" | Set-ScsiLun -MultipathPolicy "roundrobin"
        + CategoryInfo          : ObjectNotFound: (.id:String) [Get-ScsiLun], VimE
       xception
        + FullyQualifiedErrorId : Common_CommonUtil_FilterCollection_ObjectNotFoun
       d,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetScsiLun

    Get-ScsiLun : 2/8/2013 2:41:49 AM    Get-ScsiLun        Value cannot be null.
    Parameter name: moRef
    At C:\users\cz3m7g\desktop\RR.ps1:5 char:56
    + Get-cluster -Name "$cluster" | Get-VMHost | Get-ScsiLun <<<<  -canonicalName
    "$naa.id" | Set-ScsiLun -MultipathPolicy "roundrobin"
        + CategoryInfo          : NotSpecified: (:) [Get-ScsiLun], VimException
        + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomatio
       n.ViCore.Cmdlets.Commands.Host.GetScsiLun



  • 2.  RE: Modify the existing script.

    Posted Feb 08, 2013 10:59 AM

    Your script stores the text in the Id property of the $naa variable.

    Does that $naa variable have an Id property ?

    Is it defined somewhere ?



  • 3.  RE: Modify the existing script.

    Posted Feb 08, 2013 12:17 PM

    i have modified the script from $naa.id to $naa. It works fine. But at the end i get the below error message.

    Get-ScsiLun : 2/8/2013 7:14:53 AM    Get-ScsiLun        Value cannot be null.
    Parameter name: moRef
    At C:\users\cvbn\desktop\RR.ps1:5 char:56
    + Get-cluster -Name "$cluster" | Get-VMHost | Get-ScsiLun <<<<  -canonicalName
    "$naa" | Set-ScsiLun -MultipathPolicy "roundrobin"
        + CategoryInfo          : NotSpecified: (:) [Get-ScsiLun], VimException
        + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomatio
       n.ViCore.Cmdlets.Commands.Host.GetScsiLun



  • 4.  RE: Modify the existing script.
    Best Answer

    Posted Feb 08, 2013 09:58 PM

    Looks like Get-VMHost isn't placing any objects in the pipeline.

    Are you sure

    Get-cluster -Name "$cluster" | Get-VMHost

    returns any VMHost objects ?