Orchestrator Functions: VcVirtualMachineSnapshot

by Simon Sparks · January 5, 2026

To use this function add it to the class library file named vCenterServerService.ts

GitHub Repository: https://github.com/SimonSparksUK/Orchestrator

Filename: vCenterServerService.ts

public VcVirtualMachineSnapshotCreate(objVcVirtualMachine: VcVirtualMachine, strName: string, blnMemory: boolean = false, blnQuiesce: boolean = false): VcTask {

    let objDate: Date = new Date();

    let strTimestamp: string = System.formatDate(objDate, "YYYY-MM-dd HH:mm:ss");

    let strDescription: string = `Snapshot taken on ${strTimestamp} with Memory ${blnMemory ? "On" : "Off"}) and Quiesce ${blnQuiesce ? "On" : "Off"}`;

    let objVcTask: VcTask = objVcVirtualMachine.createSnapshot_Task(strName, strDescription, blnMemory, blnQuiesce);

    return objVcTask;
}

public VcVirtualMachineSnapshotDelete(objVcVirtualMachine: VcVirtualMachine, strSnapshotName: string, blnSuppressPowerOn: boolean = true, blnRemoveChildSnapshots: boolean = true): VcTask {

    let objVcVirtualMachineSnapshot: VcVirtualMachineSnapshot = this.VcVirtualMachineGetSnapshotByName(objVcVirtualMachine, strSnapshotName);

    let objVcTask: VcTask = objVcVirtualMachineSnapshot.removeSnapshot_Task(blnRemoveChildSnapshots, blnSuppressPowerOn);

    return objVcTask;
}

public VcVirtualMachineSnapshotRevertTo(objVcVirtualMachine: VcVirtualMachine, strSnapshotName: string, blnSuppressPowerOn: boolean = true): VcTask {

    let objVcVirtualMachineSnapshot: VcVirtualMachineSnapshot = this.VcVirtualMachineGetSnapshotByName(objVcVirtualMachine, strSnapshotName);

    let objVcHostSystem: VcHostSystem = null;

    let objVcTask: VcTask = objVcVirtualMachineSnapshot.revertToSnapshot_Task(objVcHostSystem, blnSuppressPowerOn);

    return objVcTask;
}

public VcVirtualMachineSnapshotRevertToCurrent(objVcVirtualMachine: VcVirtualMachine, blnSuppressPowerOn: boolean = true): VcTask {

    let objVcHostSystem: VcHostSystem = null;

    let objVcTask: VcTask = objVcVirtualMachine.revertToCurrentSnapshot_Task(objVcHostSystem, blnSuppressPowerOn);;

    return objVcTask;
}

public VcVirtualMachineSnapshotDeleteAll(objVcVirtualMachine: VcVirtualMachine, blnConsolidate: boolean = true): VcTask {

    let objVcTask: VcTask = objVcVirtualMachine.removeAllSnapshots_Task(blnConsolidate);

    return objVcTask;
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like