PoshCode Archive  Artifact [c653d6821a]

Artifact c653d6821a8d0e93e071531bcd251bca28cece74b912753873628e581b696dc8:

  • File ESXi-scratch-location.ps1 — part of check-in [322e44e9b5] at 2018-06-10 14:10:16 on branch trunk — Update custom scratch location ESXi 5.1 (user: Leon Scheltema size: 1014)

# encoding: ascii
# api: powershell
# title: ESXi scratch location
# description: Update custom scratch location ESXi 5.1
# version: 0.1
# author: Leon Scheltema
# license: CC0
# x-poshcode-id: 6202
# x-archived: 2016-05-12T10:05:33
# x-published: 2016-02-05T04:51:00
#
#
# start setting
# end setting

# User input ESXi host
$vCenter = Read-Host "Enter ESXi host FQDN"

# Connect VIserver
Connect-VIServer $vCenter

# Esxcli command pass-through to retrieve vmfs volume details
$esxcli=get-esxcli -vmhost $vCenter
$esxcli.storage.vmfs.extent.list() | ft volumename,VMFSUUID -autosize

# User input Location for persistent scratch location
$VolumeName = Read-Host "Enter Disk VolumeName"

# Get advanced setting and update value with user input
Get-AdvancedSetting -Entity (Get-VMhost -Name $vCenter) -Name "ScratchConfig.ConfiguredScratchLocation" | Set-AdvancedSetting -Value "/vmfs/volumes/$VolumeName" -Confirm:$False

# Disconnect VIserver
Disconnect-VIServer -Confirm:$false