This script is an example script and is not supported under any Zerto support program or service. The author and Zerto further disclaim all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose.
In no event shall Zerto, its authors or anyone else involved in the creation, production or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or the inability to use the sample scripts or documentation, even if the author or Zerto has been advised of the possibility of such damages. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you.
PowerShell and PowerCLI script that uses the Get-VM and Get-Stat cmdlets to collect average VM write rates and output this data to a CSV file.
Before executing this script, review the instructions below and modify the script as instructed.
-
Review the the vCenter statistics level settings, and consider the potential impact of an increase in the statistics level. When the level is increased, the vCenter database will consume more disk space, relative to how many hosts and VMs are in vCenter inventory. VMware provides an estimate of the size increase, when preparing to adjust this setting in the vSphere web client.
https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.vcenter.configuration.doc/GUID-B2F91FDE-F7FC-46C4-91D0-7AD7E4CC87FC.html
"Statistic collection intervals determine the frequency at which statistic queries occur, the length of time statistical data is stored in the database, and the type of statistical data that is collected." -
Confirm how long to collect statistics before enough average write rate data is available. Once the statistic level is changed, it will begin retaining data. There is no way for vCenter to retroactively collect data. Wait for enough average write rate data to be collected.
-
Review the prerequisites for the example PowerCLI script provided in the Zerto Scale and Benchmarking Guidelines.
Install PowerCLI: https://developer.vmware.com/powercli/installation-guide
Connect to Environment: https://developer.vmware.com/docs/powercli/latest/products/vmwarevsphereandvsan/ -
Launch the Windows PowerShell ISE, or your preferred scripting application.
-
Install the PowerCLI module from the PowerShell Gallery, or manually if no direct Internet connection is available:
Install-Module -Name VMware.PowerCLI -
If needed, temporarily configure the PowerShell session to use TLS 1.2:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -
Import the module:
Import-Module VMware.VimAutomation.Core -
If needed, set the certificate acceptance settings for the current session:
https://code.vmware.com/doc/Set-PowerCLIConfiguration.html
Set-PowerCLIConfiguration -Scope Session -InvalidCertificateAction Warn -
Connect to the vCenter server hosting the VMs that will be protected:
Connect-VIServer -Server 192.168.222.10 -Protocol https -
Open the script in the ISE. Copy and paste it into a new file if needed.
-
Modify the example script, if needed:
Change the "adddays(-7)" section of the script to match the number of days since the vCenter statistics level has been increased (up to 30).
Change the path and file name of the CSV file that will be created.