I'm trying to query for a list of datastore clusters and return only the first name. It works ok if there are multiple names, but if only one DS cluster name is returned, it only get the first character.
I'm having trouble with this command $DestDatastore = $DRClusterMaxSize.Name[0]
I want to use the same command whether it's a single or multiple DSClusters
Example:
$DRClusterMaxSize = Get-VBRServer -Name $DRHost | Find-VBRViDatastoreCluster | Where {($_.Name -like $SASDSC)}
Then I tried this:
$DestDatastore = $DRClusterMaxSize.Name[0]
Multiple DSCluster names will return the first name - that's good
If only a single DSCluster name, I only get the first character of the name
Then I tried this:
$DestDatastore = $DRClusterMaxSize.Name
Multiple DSCluster names will return the both names - I only want the first
If only a single DSCluster name, I get the single name - that's good
-
- Enthusiast
- Posts: 39
- Liked: 4 times
- Joined: Aug 20, 2014 1:00 pm
- Contact:
-
- Product Manager
- Posts: 20413
- Liked: 2301 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Trying to query for a list of datastore clusters
Can you describe your goal, please? If you want only to query vSphere resources, then, VMware PowerCLI might work better in this case? Thanks!
-
- Veeam Vanguard
- Posts: 282
- Liked: 113 times
- Joined: Apr 20, 2017 4:19 pm
- Full Name: Joe Houghes
- Location: Castle Rock, CO
- Contact:
Re: Trying to query for a list of datastore clusters
You should be able to reformat your last line and get the desired result.
Try this instead:
$DestDatastore = $DRClusterMaxSize[0].Name
Try this instead:
$DestDatastore = $DRClusterMaxSize[0].Name
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
Who is online
Users browsing this forum: No registered users and 14 guests