acavalier
Contributor
Contributor

Reduce VM memory with SRM scripting

I am trying to automatically reduce the RAM assigned to a VM before SRM starts the VM during a test or recovery.

I want to adjust each server's memory seperately via the additional recovery step feature.

The very little bit of into I could find on this subject has not worked after trying to 9 hours now.

I can get the command to complete at the prompt if I issue it in pieces.  I'm having trouble

Please assist if you can.

I am calling a batch file from the Recovery Plan via an additional step just before the Power On VM step.

Add Recovery Step.JPG

This is the batch file - bfs.bat

@echo off
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -psc "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1"& '%1'"

*************

This is the script file - bfs.ps1

connect-viserver bmsdrvc Set-VM bfs -MemoryMB "1024" -Confirm:$FALSE

** I've tried to remove the "connect-viserver bmsdrvc" , I've tried to put a | (pipe) before the "Set-VM" .

I just can't make it work.

Help if you can please.

Al Cavalier

Tags (4)
0 Kudos
1 Reply
mal_michael
Commander
Commander

Hi,

Here

http://searchvmware.techtarget.com/tip/Customizing-VMware-Site-Recovery-Manager-recovery-plans-with-...

you can find a detailed guide on using PowerCLI with SRM.

Afew things to pay attention to:

1. Don't remove connect-viserver, it is required to establish a connection to vCenter

2. Provide credentials in connect-viserver command, othervise it will try to connect with SRM service account credentials. Since most of the chances you are using LocalSytem account for that, it obviously cannot connect to vCenter.

3. Put set-vm on separate line

4. Don't forget to use "disconnect-viserver -confirm:$false" to close the session.

Michael.

0 Kudos