VMware Cloud Community
Morrow201110141
Contributor
Contributor

Remote PowerCLI during SRM failover

Hello,

I am trying to build a script that will change the NIC settings on a VM from static to DHCP during the 'Post Power On'  stage of the SRM recovery process.

A little research online suggests that i need to use the PowerCLI cmdlet Invoke-VMScript with $env:vmware_vm_name in order to call a second script and run in on the VM that SRM is recovering at that moment. I have put together the following 'Invoke' script after some trial and error:

Connect-VIServer servername.domain.com
Invoke-VMScript -VM $env:vmware_vm_name -ScriptType PowerShell -ScriptText c:\scripts\setdynamic.ps1 -HostUser root -HostPassword password -GuestUser administrator -GuestPassword password

When i run the script as part of the recovery plan i recieve the following in the SRM logs:

[#2] Name                           Port  User                         
[#2] ----                           ----  ----                         
[#2] drvspheresvr1.tta.gov.uk       443   TTA\SRMservice               
[#2] WARNING: The version of VMware Tools on VM 'SRM-test' is out of date and may
[#2] cause Invoke-VMScript to work improperly.
[#2] The term 'c:\scripts\setdynamic.ps1' is not recognized as the name of a cmdlet,
[#2]  function, script file, or operable program. Check the spelling of the name, or
[#2]  if a path was included, verify that the path is correct and try again.
[#2] At line:1 char:29
[#2] + & {c:\scripts\setdynamic.ps1 <<<< }
[#2]     + CategoryInfo          : ObjectNotFound: (c:\scripts\setdynamic.ps1:Strin
[#2]    g) [], CommandNotFoundException
[#2]     + FullyQualifiedErrorId : CommandNotFoundException
[#2] 
[#2]
[#2]
[#2]
[#2] ",
[#2]    returnValue = 0,

I have tried a few different things to get the script to succefully call the second PS script, but to no avail. As i am new to PowerShell and SRM in general i feel i must be missing something obvious!

Can anyone point out what i might be doing wrong?

0 Kudos
1 Reply
Morrow201110141
Contributor
Contributor

Slight update to this, i copied the scripts folder to the VM itself and the script ran successfully, So it seems that the line i posted above is trying to call the script from the local C drive of the VM, which i not what i want it to do and is contrary to my understanding of how it would work 😕

Any ideas?

0 Kudos