Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 230777

how to clip the domain component of the host name for script use

$
0
0

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


Viewing all articles
Browse latest Browse all 230777

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>