SET isodt=%date:~10,4%-%date:~7,2%-%date:~4,2% %time:~0,2%-%time:~3,2%-%time:~6,2% IF %1==Test ECHO %2 %isodt% >> c:\ZertoScripts\Results\TestedVPGs.txt |
##The following are a list of requirements for this script: ## - This script must be present in the same directory on both sites listed in ## the Manage VPGs dialog ## - PowerShell v2.0 installed on both Zerto Virtual Managers ## - VMWare PowerCLI installed on both Zerto Virtual Managers ## ##This script was written by Zerto Support and is used at the customer's own risk ## and discretion. ## ##Note: The desired resource pool MUST exist on the hypervisor manager prior to ##running this script. ## ##To run this script from the VPG screen, an example command is 'powershell.exe' ##with the parameter 'C:\ZertoScripts\Move-VMs.ps1' ## ##START OF SCRIPT ## ##PowerCLI requires remote signed execution policy - if this is not enabled, ##it may be enabled here by uncommenting the line below. ##Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force ##Below are the variables that must be configured. |
##Variables: ##The location of this script $strMoveScriptLoc = "C:\Zerto Scripts\" ##vCenter IP address $strVCenterIP = "10.10.10.10" ##vCenter user account to use; account must have ability to move desired machines $strVCUser = "Administrator" ##vcenter user password $strVCPw = "password" ##Name of resource pool in vCenter $strResPool = "ResourcePool" ##Array of VMs to move; it includes ALL VMs in the VPG and is case sensitive. $strVMtoMove = @("VM-1", "VM-2", "VM-3") ##The PowerCLI snap-in must first be registered Add-PSSnapin VMware.VimAutomation.Core ##Move to directory where script is located CD $strMoveScriptLoc ##Connect to target VC server based on variables above Connect-VIServer -Server $strVCenterIP -Protocol https -User $strVCUser -Password $strVCPw ##execute the move for each VM specified foreach ($objVM in $strVMtoMove){ Move-VM -VM $objVM -Destination $strResPool } ##Disconnect from session with VC server Disconnect-VIServer -Server $strVCenterIP -Force ##End of script |