VMware Cloud Community
danscorpio
Contributor
Contributor

VM Snapshot with Power shell cli

Hello All

I do not have much knowledge of Powershell but I'm trying to create a snapshot in vcloud.link-connect.com with below script but I'm getting an error as term "Connect-CIServer is not recognized.

I would really appreciate if you could help me fix this issue. please find my script below.

if ( !(Get-Module -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) ) {

"C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"

}

$srv= connect-CIServer -Server vcloud.link-connect.com -user xx -Password xxx -Org xxx

$vm10 = Get-CIvm "xxxx"-

$vm10.ExtensionData.RemoveAllSnapshots()

$vm10.ExtensionData.CreateSnapshot($null,$null,"$null","$null")

Many Thanks

Dan

Reply
0 Kudos
4 Replies
Zsoldier
Expert
Expert

What version of PowerCLI are you using?  Latest versions, you'd have to:

import-module VMware.VimAutomation.Cloud

or

import-module vmware.powercli

Chris Nakagaki (中垣浩一)
Blog: https://tech.zsoldier.com
Twitter: @zsoldier
Reply
0 Kudos
danscorpio
Contributor
Contributor

Hi

I'm using 5.5 Release 1.

Thank you for taking time to reply my question.

Would really appreciate if you continue help to fix this issue.

Reply
0 Kudos
danscorpio
Contributor
Contributor

Hi

Could someone please give  a professional touch to this script so that I could Revert snapshot with results and then take a snapshot again

I would really appreciate your response.

Thanks

if ( !(Get-Module -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) ) {

"C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"

}

$srv= connect-CIServer -Server vcloud.link-connect.com -user xx -Password xxx -Org xxx

$vm = Get-CIvm "xxxx"-

$vm.ExtensionData.RemoveAllSnapshots() ???? Need Revert Script please !!

$vm.ExtensionData.CreateSnapshot($null,$null,"$null","$null")

Reply
0 Kudos
RvdNieuwendijk
Leadership
Leadership

You can use $vm.ExtensionData.RevertToCurrentSnapshot() to revert to the current snapshot.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos