Hi,
I'm trying to rename my local datastores <hostname>-local.
Pretty easy in theory especially as that is the only datastore on my host right now.
I do this
$vmhosts = get-vmhost -location <datacenter of choice>
for each $vmhost in $vmhosts {
get-vmhost $vmhost | get datastore | set-datastore -name "$vmhost-local"
}
Only they get named
myhost.mydomain.com-local instead of
myhost-local
I'm fairly new to scripting and I'm not sure how to cut the $vmhost down to remove the .mydomain.com off the end.
I notice in powershell they mention that you can use .string to shorten strings only that doesn't seem to work.
Any help would be great.
Thanks