VMware Cloud Community
yosingh
Enthusiast
Enthusiast

when host boots to upgrade to 6.7 from audodeploy , I loose my nfs datastore. need a script to mount the host again to nfs datastores they were connected previously.

when host boots to upgrade (from 6.0to 6.7) from audodeploy , I loose my nfs datastores. need a script to mount the host again to nfs datastores they were connected previously.

I am doing 1 or 2 hosts at a time. Currently I am going to previous host (working one ) then go the datastore and right click and mount the host which is rebooted from autodeploy.

You can take reference from other hosts in the cluster

Tags (2)
Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership

You could do the following to export all NFS info from all your ESXi nodes.

Get-VMHost -PipelineVariable esx |

ForEach-Object -Process {

    Get-Datastore -RelatedObject $esx | where{$_.Type -eq 'NFS'} |

    Select @{N='VMHost';E={$esx.Name}},

        @{N='Datastore';E={$_.Name}},

        @{N='RemoteHost';E={$_.RemoteHost -join '|'}},

        RemotePath

} | Export-Csv -Path .\nfs-datastore.csv -NoTypeInformation -UseCulture

Then use the following to re-create those datastores.

$esxName = 'MyEsx'

$esx = Get-VMHost -Name $esxName


Import-Csv -Path .\nfs-datastore.csv -UseCulture -PipelineVariable row |

where{$_.VMhost -eq $esxName} |

ForEach-Object -Process {

    New-Datastore -VMHost $esx -Name $row.Datastore -Nfs -NfsHost $row.RemoteHost.Split('|') -Path $row.RemotePath -Confirm:$false

}


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

Reply
0 Kudos