Using PowerShell to remove Snapshots from Virtual Machines in vSphere

Although vSphere 5.5 has a scheduled task to create Snapshots, it appears to be missing a scheduled task to remove them.

I had to find a way of automating the removal of the Snapshots for specific Virtual Machines at a specific time (ie not during business hours).

To do this required 3 things, a Scheduled Task and a PowerShell script using the VMWare Snapin and a TXT document with the hostname of the Virtual Machine that needs the Snapshot to be removed.

This script is quite simple – it connects to the vSphere server, checks for a VM name under a TXT document that people add their servers to and then when the scheduled task runs it removes the Snapshot for that VM and clears the TXT document ready for the next day.

Note: You can add Credentials for the vSphere connection to the script, however I am running the script under a Service Account that has been granted Remove Snapshot rights.

Feel free to add any comments, suggestions to the comments section below.

Using PowerShell to remove App-V packages from a Windows workstation

App-V applications, usually store their data locally if they are not streamed. Sometimes an Application will have problems, either hasn’t been downloaded or some other reason.

One of the solutions that can be ran is to clear the App-V package store of a workstation, allowing you to reevaluate and download the packages back to the affected computer.

This script is pretty simple and something I made a year ago for some colleagues experiencing App-V application cache issues so decided to share it here. This requires the App-VClient PowerShell module – usually installed by default as part of the App-V client.


Feel free to let me know your thoughts in the comments below

Using PowerShell to setup Automatic Logon on Windows Servers

Some ‘server based’ applications require to be logged into into a service account to allow an Application or service to run, These applications usually require manual intervention by systems administrators to login to the account manually after a server restart.

There are many ways to setup Automatic Logon, using “control userpasswords2” via the Run Prompt, using Third Party utilities like LogonExpert or SysInternals Autologon for Windows  this simply using RegEdit and setting them manually.

I have created a PowerShell script for editing the registry to set this manually in a standardized way and could be ran remotely. It is pretty simple and only requires version 1 of PowerShell.


Read more

Enabling Disk Cleanup in Windows Server 2008 R2

In Server 2008 and Server 2008 R2, Disk Cleanup is Disabled by default. This is how you can enable disk cleanup in Windows Server 2008 R2 – 64bit.

You can enable the Desktop Experience role (which requires a restart to complete) but the easiest way is to copy the files from the WinSXS directory to the relevant directories – as mentioned below

OS File Location
Windows Server 2008 R2 C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe
Windows Server 2008 R2 C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui
  1. Copy Cleanmgr.exe to %systemroot%\System32
  2. Copy Cleanmgr.exe.mui to %systemroot%\System32\en-US
  3. Run Cleanmgr.exe from an elevated Command Prompt