Categories
ESXi PowerShell Scripts theVESI Virtualisation VMware vSphere

Function to rename the local datastore of a new installed ESXi

This is a small function to rename the local datastore of a fresh installed ESXi server from datastore1 to SERVERNAME-local.

$ServerIP="192.168.4.3"
function renameds {
	$vmHost = Get-VMHost -Name $ServerIP
	$dsname = $vmHost + "-local"
	Get-Datastore -Name datastore* | Set-Datastore -Name $dsname
}

3 replies on “Function to rename the local datastore of a new installed ESXi”

So what happens if the host has 2 or more local datastores, both containing the text “datastore”? Seems like anything above the first would fail with an attempt to duplicate the name.

Correct the coding is only valid for 1 local datastore. But it is easy to extend the script for multiple datastores. For example you could first get all datastores from the ESXi write them into an array and afterwards change the name of each datastore (servername-local-1, servername-local-2).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.