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

Re: How to extend/optimize this multi vc datastore inventory script

$
0
0

In method 1 you can avoid that the script stops when the VC is in trouble by adding the -ErrorAction SilentlyContinue parameter on the Connect-VIServer.

You will have to test yourself if the connected worked or not, and depending on the result retrieve the data or not.

Something like this

 

$vcName="MyVC"

$vc
=Connect-VIServer-Server$vcName-ErrorActionSilentlyContinue
if($vc.IsConnected){# Collect the date}else{# Connection to VC failed, display error message  Write-Error"Connection to $($vcName) failed !"
}

 

Method 2 can indeed take a considerable time in a larger environment.

Here you can optimise the speed by using the Get-View cmdlet and by using the Property parameter.

Like this

 

Get-View-ViewTypeHostSystem-Property"Name","VM"

 

and limit the properties to only the ones you need in the script.

 

Method 4 would my personal choice, you run/schedule the inventory script from a single station and you use a PowerShell feature to "multi-thread".

But be aware that the Start-Job in combination with a PowerCLI script needs some specific coding in your script.


Viewing all articles
Browse latest Browse all 228891

Trending Articles