Hi LucD,
I have a query..
1. Convert Template to VM
2. Power On the VM
3. Patch the VM with
3. Power Off
4. Convert to Template
Operating System: Linux
Looking forward to your reply, thanks for the help.
What is in fact the question?
All these steps, besides 3, are simple cmdlets.
And 3 is of course Guest OS dependent
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Thank you for the response.
I was able to figure out about template to VM to template cmdlets and it works. But I'm stuck at assigning the IP address to the VM (Linux OS) using PowerShell - is there any possibility to assign IP address to the VM using powerCLI cmdlets.
I came across this cmdlet but this is for windows, not really sure if this works for Linux:
New-NetIPAddress
Kindly help.
I'm afraid you will have to do that inside the Guest OS itself.
Most Linux systems allow you to do that via config files.
You can for example do that via Invoke-VMScript and run a sed command inside the Guest OS.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
We have a static IP address on all our templates. Changing the IP is part of the deployment of a VM.
We time the convert from template to VM and power on with our patch window. When SCCM or Satellite pushes patches, the VM is up and running. Then, power off and convert back to a template. When things don't work correctly, it's usually on the SCCM or Satellite side.
You can set the IP using Invoke-VMScritp, with this command you need to run a OS command to set IP for the guest
Thanks for basically repeating my answer.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you for your response earlier 🙂
Luc, I have another question:
I want to assign a IP address to the linux VM so, I would be running this script:
$VM = Get-VM -Name "Linux-Test-TemplateRHEL7"
$code = @'
ls > "tmp/test.txt"
ip address add 1.1.1.1/24 dev ens199 (network interface)
'@
Invoke-VMScript -VM $VM -ScriptType bash -ScriptText $code -GuestUser "<string>" -GuestPassword "<string>"
So the question is.. Do we have any way/cmdlets to get the information about the network interface of the linux VM? without logging into the VM after converting it from template to VM.
Because right now my script works but I was successful only after logging into the VM and manually finding the network interface (ens199).
Kindly help. Thanks in advance 🙂
Afaik, no.
The advantage of using Invoke-VMScript is that it only requires the VMware Tools to be running.
There is no need for a network connection in the Guest OS.
So instead of logging on, you can launch the required command in the Guest OS, analyse the output and then set the network.
No need to logon at least
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference