Hi Patrick,
I have created a couple of scripts to check those settings and create if needed.
My first one will just check the settings and show that information to make sure which ones already have moved the scratch to a datastore, or using the default (in this case SD Cards).
###### Credentials and vCenter connection ######
$user = "uservCenter"
$pwd = "password"
$vCenter = 'vCenterIP'
Connect-VIServer $vCenter -User $user -Password $pwd
### vCenter Server Name(FQNP)
$vCentName = [system.net.dns]::GetHostByAddress($vCenter).hostname
################################################
cls
$Cluster = Get-Cluster "addCluster"
$ESXiHosts = $Cluster | Get-VMHost | where {$_.PowerState -eq "PoweredOn"} | sort
#$esxihosts = Get-VMHost | where {$_.PowerState -eq "PoweredOn"} | sort
$Output=@()
$ConfiguredLocation = "ScratchConfig.ConfiguredScratchLocation"
$CurrentLocation = "ScratchConfig.CurrentScratchLocation"
$RamDisk = "UserVars.ToolsRamdisk"
$USBCoredump = "VMkernel.Boot.allowCoreDumpOnUsb"
$USBCoredumpPartition = "VMkernel.Boot.autoPartitionCreateUSBCoreDumpPartition"
$SysGlobal = "Syslog.global.logDir"
foreach($ESXi in $ESXiHosts ){
$value1 = Get-AdvancedSetting -Entity $ESXi -Name $ConfiguredLocation
$value2 = Get-AdvancedSetting -Entity $ESXi -Name $CurrentLocation
$value3 = Get-AdvancedSetting -Entity $ESXi -Name $RamDisk
$value4 = Get-AdvancedSetting -Entity $ESXi -Name $USBCoredump
$value5 = Get-AdvancedSetting -Entity $ESXi -Name $USBCoredumpPartition
$value6 = Get-AdvancedSetting -Entity $ESXi -Name $SysGlobal
If ($value3.Value -eq $true) { $value3 = "Enable" } elseif ($value3.Value -eq $false) { $value3 = "Disable" }
$tmp = [pscustomobject] @{
"ESXi host" = $ESXi;
"Configured Location" = $value1.Value;
"Current Location" = $value2.Value;
"UserVars ToolsRamdisk" = $value3;
"Allow Core Dump On USB" = $value4.Value;
"Auto USB Core Dump Partition" = $value5.value;
"Sys Global Log Folder" = $value6.value;
}
$Output+= $tmp
}
$Output | FT *
$ThisDate = Get-Date -format dd_MM
$Path=$PSScriptRoot
$kFile = "$Path\$kFile_$vCentName-$ThisDate.csv"
$Output | Export-Csv $kFile -NoTypeInformation -UseCulture
$Output | Out-GridView
After I just need to add the datastore where I want to move the scratch and the script will create the folder and move the setting.
Connect-VIServer $vCenter -User $user -Password $pwd
### vCenter Server Name(FQNP)
$vCentName = [system.net.dns]::GetHostByAddress($vCenter).hostname
################################################
cls
$Cluster = Get-Cluster "add-Cluster"
$dsName = 'add-Datastore'
$pathPrefix = '.locker_'
$ds = Get-Datastore -Name $dsName
New-PSDrive -Location $ds -Name DS -PSProvider VimDatastore -Root '' | Out-Null
$Cluster | 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
Get-AdvancedSetting -Entity $_ -Name "Syslog.global.logDir" |
Set-AdvancedSetting -Value "[] /scratch/log" -Confirm:$false | Out-Null
}
Remove-PSDrive -Name DS -Confirm:$false
PS: The above I created from a script wrote by the guru
Hope this helps you automate these changes.