1. A method for generating a snapshot of a virtual machine, comprising: receiving a trigger to generate the snapshot of the virtual machine; in response to the trigger, transmitting a first command to lock an operating system being executed by the virtual machine, wherein the first command is directed to the virtual machine and causes the virtual machine to execute one or more scripts included in the operating system to force the operating system into a locked state; and transmitting a second command to create the snapshot of the virtual machine, wherein, in the snapshot, the operating system executed by the virtual machine is in the locked state and protected by a login screen that requires credentials of an authorized user to be entered to access the operating system after the virtual machine is restored from the snapshot, and wherein the second command is transmitted after an acknowledgement is received that indicates the operating system is in the locked state.