Dear All,
We have one common NFS datastore configured / mapped on all clusters. We are planning to configure persistent scratch partition on NFS datastore for all ESXi hosts. With the help of PowerCLI script we need to perform below Steps
- Create a folder on NFS datastore for every ESXi Host, folder name must start from ".locker _ESXiHostNameFQDN"
- Configure scratch partition on all ESXi host. For every ESXi host log path must be respective ESXi folder, for example if we are configuring scratch partition for ESXi1 then scratch path must be "/vmfs/volume/NFS-DataStore-UUID/.locker_ESXi1FQDN" and if we are configuring scratch partition for ESXi2 then the scratch path must be ""/vmfs/volume/NFS-DataStore-UUID/.locker_ESXi2FQDN"
Could you please help me with the powercli script for the same.
Try like this
$dsName = 'NFS-DataStore'
$pathPrefix = '.locker_'
$ds = Get-Datastore -Name $dsName
New-PSDrive -Location $ds -Name DS -PSProvider VimDatastore -Root '' | Out-Null
Get-VMHost | ForEach-Object -Process {
$folder = "$($pathPrefix)$($_.Name)"
$folderPath = "/vmfs/volumes/$($ds.Name)/$folder"
New-Item -Path "DS:\$folder" -ItemType Directory | Out-Null
Get-AdvancedSetting -Entity $_ -Name "ScratchConfig.ConfiguredScratchLocation" |
Set-AdvancedSetting -Value $folderPath -Confirm:$false | Out-Null
}
Remove-PSDrive -Name DS -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You might consider setting the syslog to the same location as well.
Just add the following lines, after the ScratchConfig.ConfiguredScratchLocation ones, inside the loop.
Get-AdvancedSetting -Entity $_ -Name "Syslog.global.logDir" |
Set-AdvancedSetting -Value "[] /scratch/log" -Confirm:$false | Out-Null
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference