VMware Cloud Community
GaneshShastri
Enthusiast
Enthusiast

Need pcli script to take snapshot

Hello Team,

I am upgrading vRops appliance, before that I want to take 25 vm's snapshot, which are deployed in different VC's. Can anybody have power shell script, which it will take snapshot without logging into VC's from gui, and take snapshot through script.

My Idea is

Creating csv file, which contains 2 columns (VM Name ,  VC Name) 

15 VM's are located in 1 VC - While connecting to this VC, it needs to prompt credential

The rest 10 VM's are located in different VC's with respect to country and region. While accessing these VC's again it needs to prompt credential.

Note-> I can access these VM's from one Terminal Server (N/w are through from respective TS).

Can anybody please help me on this, so that i can save time to login to VC's and take snapshot,

Regards

Ganesh Shastri.

Reply
0 Kudos
1 Reply
GaneshRam
VMware Employee
VMware Employee

hi GaneshShastri

Following code might help you. you should tweek it as it does not match your req exactly.

New-VICredentialStoreItem -Host <VC1> -User <uname> -Password <pwd>

New-VICredentialStoreItem -Host <VC2> -User <uname> -Password <pwd>

Foreach ($cred in Get-VICredentialStoreItem)

{

  $hostname = $cred.Host.ToString()

  Connect-VIServer $hostname

  Foreach ($vm in Get-VM)

  {

    $vmname = $vm.Name.ToString()

    New-Snapshot -VM $vmname -Name preVropsUpgrade 

  }

}

If you find this or any other answer useful please mark the answer as correct or helpful.
Reply
0 Kudos