PoshCode Archive  Artifact [fb78099b0e]

Artifact fb78099b0e9e71203a94e198bc169ce8b6141d95d2279e0539c0077694b76085:

  • File ESXi-scratch-location.ps1 — part of check-in [ec99011a65] at 2018-06-10 13:42:06 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: 4507
# x-archived: 2016-05-17T08:15:03
# x-published: 2016-10-07T12:47: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