Last active
December 1, 2015 16:03
-
-
Save NamedJason/d35f7edd3125d41555ae to your computer and use it in GitHub Desktop.
Renames local datastores on an ESXi host based on the hostname to which the datastore is local.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Renames local datastores on ESXi hosts to use the hostname plus a specified suffix. | |
# Usage: Rename-Local.ps1 -cluster <Cluster name> -suffix <Datastore Suffix> | |
# Website: http://virtuallyjason.blogspot.com/ | |
# Reference: http://virtuallyjason.blogspot.com/2015/12/renaming-esxi-host-local-datastores-by.html | |
# Original script by VMNick0 at http://www.pcli.me/?p=25 | |
[cmdletbinding(SupportsShouldProcess=$True)] | |
param( | |
$cluster = "sac-cluster", | |
$suffix = "-local" | |
) | |
get-cluster $cluster | get-vmhost | % { | |
$_ | get-datastore | ? {$_.name -match "^datastore1( \(\d+\))?$"} | set-datastore -name "$($_.name.split(".")[0])$suffix" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment