How to convert a VSphere PowerCLI script as batch file to execute by VMware Site recovery manager recovery plan. Please find the attached word document for the error details when I plugged with SRM recovery plan as a command to exectue
Have a look at PowerCLI and SRM - what you need to know!
You will have to execute PowerShell and pass the script as a parameter.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Before I forget, remember that SRM will run the PowerCLI scripts in 32-bit mode.
That means you have to use the C:\Windows\SysWOW64\WindowsPowerShell\v1.0 path on a 64-bit machine !
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Lucd,
what should be the full path I should mention
C:\Windows\SysWOW64\WindowsPowerShell\v1.0
That should be
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -file g:\scripts\listofvms.ps1
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The PowerCLI script seems to exit with a funny exit code (that's the 196,608 number you see).
Are you sure the script is running correctly ?
Did you test it with the account under which it runs in SRM ?
You could also try adding the consolefile on the PowerShell command.
Something like
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -psc "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -file C:\Vaseline\vase.ps1
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This is the below PowerCLI script:-
Connect-VIServer 10.0.0.1
foreach($nic in (Get-Cluster -Name VASE | Get-VM -Name Vase*| Get-NetworkAdapter)){
switch -regex ($nic.Name){
'.+[1|2|3]'{Set-NetworkAdapter -NetworkAdapter $nic -Connected:$false -StartConnected:$false -Confirm:$false}
'.+[4|5|6]'{Set-NetworkAdapter -NetworkAdapter $nic -Connected:$true -StartConnected:$true -Confirm:$false}
}
}
Disconnect-VIServer 10.0.01 -Confirm:$false
If I manually login to the VSphere PowerCLi and run the script it will work fine. Could you please check how can I fit this in the recovery plan in the VMware SRM 4.1.2 this is very important to me.