Automation

 View Only
  • 1.  Set HA Restart Priority from a csv file

    Posted Nov 05, 2014 11:04 PM

    Hello

    I have a Problem with set HA Restart Priority from a csv file on VMs.

    My script part is like that:

    if ($Export)

    {

    # Export to csv

    $mycluster = Get-Cluster -Name $Cluster

    $mycluster.ExtensionData.Configuration.DasVmConfig |

    Select @{N="VM";E={Get-View $_.Key -Property Name | Select -ExpandProperty Name}},

    @{N="RestartPriority";E={$_.RestartPriority}} |

    Export-Csv $Path\HARestartPrio.csv -NoTypeInformation -UseCulture }

    if ($Set)

    {

    # Set from csv

    $Import = Import-Csv $Path\HARestartPrio.csv

    foreach ($line in $Import)

    { set-vm -vm $line."VM" -HARestartPriority $line."RestartPriority" -Confirm:$false } }

    When I will set the priority, the CLI give an error back:

    The HARestartPriority Parameter can not check. The Argument is Null or empty

    What is wrong in my script? Have you any ideas?



  • 2.  RE: Set HA Restart Priority from a csv file

    Posted Nov 05, 2014 11:18 PM

    Oho, I found the mistake :smileyblush:.

    The -UseCulture switch in the export command is the problem. Without this, the script works fine.

    Sorry for this post....



  • 3.  RE: Set HA Restart Priority from a csv file
    Best Answer

    Posted Nov 06, 2014 01:48 AM

    It's not the Export-Csv that is the problem imho, you should also specify the UseCulture switch on the Import-Csv cmdlet.



  • 4.  RE: Set HA Restart Priority from a csv file

    Posted Nov 06, 2014 12:05 PM

    Ah ok, thanks Luc. :smileyhappy: